2007/12/1, Christoph Boget <[EMAIL PROTECTED]>:
>
> 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.

Reply via email to