RE: detecting negative numbers

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

 



On 17 July 2006 01:07, Dave W wrote:

> 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.

The absolute simplest way to do this is what you originally had.  I would not look further than

    if ($quant<$amount)
       // $quant-$amount is negative

If I were reading your code, I would find both if(($quant-$amount)<0) and if(neg_num($quant-$amount)) more obfuscating than if($quant<$amount).

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: m.ford@xxxxxxxxxxxxxx
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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

  Powered by Linux