Re: sprintf() oddness

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

 



2007/12/1, Christoph Boget <christoph.boget@xxxxxxxxx>:
>
> Why does
>
> sprintf( '%.03f', 0.15250000 )
>
> return 0.152 while
>
> sprintf( '%.03f', 0.15750000 )
>
> return 0.158?
>


Welcome to the world of f**** floating point numbers. Discrete mathematics,
leave all hope, ye that enter.

It's the way floating point number behave (a computational error that's more
problematic that one may suspect). You'll have to live with it, or use an
extension for arbitrary sized numbers (or fixed point numbers).

Why we have to accept this kind of behavior?

Long story short: they are excellent for computations required in 3d
graphics, they are lousy for business applications...
...and we all know that computers are for playing 3d games, don't we?

XD

Sorry about the noise.

[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