[DGD] Float precision loss

Petter Nyström md1pette at mdstud.chalmers.se
Thu Apr 28 10:33:01 CEST 2005


> It's not a bug at all - the fault is in your expectations of the behaviour
> of floating point numbers.  I just tried the same thing in Lua and Haskell,
> and got a similar result.
>
> 4.3 has an exact representation in decimal, but not in binary.  When you
> add 5.0, the result is more than double 4.3.  That means it will be
> normalised - the mantissa will be shifted and the exponent increased.
> That means bits will be lost.

Oh, I see.  Thanks for the quick reply!

Regards,

Jimorie



More information about the DGD mailing list