Re: Round

From: Date: Wed, 29 Aug 2007 18:41:35 +0000
Subject: Re: Round
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.general 
Request: Send a blank email to php-general+get-261478@lists.php.net to get a copy of this message
PHP-Gen wrote:
I believe there is some confusion on what ABS actually does. Ignoring all the rounding that you are trying to do ABS is a very simple function. ABS definition: Returns the absolute value of number. What that means is. Abs(1) = 1 Abs(2) = 2 Abs(3) = 3 Abs(0) = 0 Abs(-1) = 1 Abs(-2) = 2 Abs(-3) = 3 Simply put, returns the positive value of the number given. Thus if you put it on a negative number it will always return positive. This most likely doesn't help what your trying to do, but I wanted to clarify this as you keep stating you are expecting a -1 when you use the ABS function. Unless someone has some trick that I don't know about, ABS will NEVER return a negative number.
Well, just to clarify, it was not I who suggested abs() as the fix. You can look back to see who first suggested it your self. First off, I completely understand what abs() does, I did passed my "basic math" class... Secondly, I have been the one trying to point out how this is the wrong approach. Finally, from what I can tell, the OP wasn't looking for a solution. He was looking for an answer as to why it returned -0 and not 0. -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare

« previous php.general (#261478) next »