Re: [PHP-DB] detecting negative numbers
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 <[EMAIL PROTECTED]> 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
Re: [PHP-DB] detecting negative numbers
-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- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] detecting negative numbers
They are both positive numbers. I want to see if, when subtract, do they equal a negative number? On 7/16/06, Peter Beckman <[EMAIL PROTECTED]> wrote: On Sun, 16 Jul 2006, 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? I'm not sure which "result" you are refering to, but this echo's if: $quant is greater than $amount $amount is less than 0 $quant is less than 0 if ($quant > $amount or $amount < 0 or $quant < 0) { echo "You don't have that many!"; } --- Peter Beckman Internet Guy [EMAIL PROTECTED] http://www.purplecow.com/ --- -- Dave W
Re: [PHP-DB] detecting negative numbers
On Sun, 16 Jul 2006, 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? I'm not sure which "result" you are refering to, but this echo's if: $quant is greater than $amount $amount is less than 0 $quant is less than 0 if ($quant > $amount or $amount < 0 or $quant < 0) { echo "You don't have that many!"; } --- Peter Beckman Internet Guy [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] detecting negative numbers
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? -- Dave W