Re: detecting negative numbers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



No, I get it. I just thought that there might have been some built in
function like if(neg_num($quant - $amount))
or something like that. I know how to do it, but I thought that there might
have been an alternate method. Just because I asked a simple question
doesn't mean I'm stupid, I'm just curious if there is a simpler way to do an
already simple task.

On 7/16/06, Stut <stuttle@xxxxxxxxx> wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dave W wrote:
> Currently I have this:
>
> if($quant > $amount) {echo "You don't have that many!"; }
>
> $quant is the user inputted amount and $amount is the amount that they
> actually have. Is there any way of checking if the result is negative
> rather
> than doing what I have above?

Not sure which way around you want it, but I think this is what you are
after...

if (($quant - $amount) < 0)
{
    echo "You don't have that many!";
}

I don't mean any offense, but the possibility that someone who couldn't
figure that out is writing PHP code scares me. You might want to think
about Googling for an absolute beginners guide to programming before
continuing.

- -Stut
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEusYz2WdB7L+YMm4RAqGPAJ0QqkgfApO6h0GR9lXa47WyAhSsugCfaymW
Ba+bqZRbrcv6CuZ6g7FJJjw=
=ktnc
-----END PGP SIGNATURE-----




--
Dave W

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux