Re: How to test if a number is negative
| From: | Miles Thompson | Date: | Thu, 26 Sep 2002 02:16:04 +0000 |
| Subject: | Re: How to test if a number is negative | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-117662@lists.php.net to get a copy of this message | ||
Or, as my teenage son, who is smarter than me, suggests ...
1 / $x + abs( $x )which yields 1/0 if $x is neg. (He didn't go into trapping for the error ... sigh.) Miles At 11:07 PM 9/25/2002 -0300, Miles Thompson wrote:
$x = -1; if ($x < 0 ){echo "Negative";elseecho "Positive";} Or am I missing something? Miles At 07:02 PM 9/25/2002 -0700, Mike Dunlop wrote:I've look through all the numerican functions but can't readily see a way to test for a negative number e.g -7 Any ideas on how to do this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php