From: <[EMAIL PROTECTED]>

> please suppose PHP 4.3.2 and $number=502,3550
>
> number_format($number,2,'.',' ') returns 502.36.
>
> It seems ok, but if $number=253,0650
>
> number_format($number,2,'.',' ') returns 253.06 instead of 253.07.
>
> Why?
> I've noticed this non-coherent approximation behaviour when
> 3rd decimal number is 5 and decimals are two many many
> times.

Isn't there some "rule" where you round up on odd numbers and don't round up
on even, otherwise it comes out unevenly rounded up?

So 0.15, 0.35, 0.55 will be rounded up to 0.2, 0.4, and 0.6, respectively,
whereas 0.25, 0.45, 0.65 will be rounded down to 0.2, 0.4, and 0.6,
respectively...

Your test cases seem to fit this.

---John Holmes...

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

Reply via email to