Re: Round

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

 



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

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux