sprintf() oddness

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

 



Why does

sprintf( '%.03f', 0.15250000 )

return 0.152 while

sprintf( '%.03f', 0.15750000 )

return 0.158?

The 4th significant digit in both cases is '5' but in the first case, it's
rounded down but in the second case it is rounded up.  Is sprintf() basing
it's decision on the value of the 3rd significant digit?  If so, why?
Shouldn't rounding decisions be based on subsequent digits and not preceding
ones?

I am using PHP 4.3.11

thnx,
Christoph

[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