Thanks !
abs() will not work for me, because I may have na negative numbers, but with
round() it worked !

10x


"John W. Holmes" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Rosen wrote:
>
> > I use some numbers from mysql table and other local vars to calculate
one
> > number.
> > But on one calc I receive thath $value=4.5474735088646E-013;
> > This must be zero (0) - I see all vars and calc then with calculator. I
use
> > function number_format($value, 2, ".", "" ) and it return me -0.00
>
> When you use floating point numbers, you can get small errors like this.
> To the computer, 4.54E-13 is about the same as zero. number_format()
> returns the correct result... well, the negative sign may throw you off.
> You can use abs() and round() to get what you want, more than likely.
>
> The thing to remember and react accordingly to is that for floating
> point numbers, 2.0 - 1.5 can equal 0.4999999999999999 and be "correct"
> because of the precision.
>
> -- 
> ---John Holmes...
>
> Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
>
> php|architect: The Magazine for PHP Professionals – www.phparch.com

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

Reply via email to