[Haskell-beginners] How to improve the accuracy of floating point calculation?

KC kc1956 at gmail.com
Wed Feb 6 02:58:33 CET 2013


I should have been more precise; I truncated my own remarks.

0.1 cannot be represented exactly in floating point because it is not
a power of two; whereas, 0.5 is 1/2 = 2^(-1).

Floating point stores its mantissa as binary bits.


On Tue, Feb 5, 2013 at 4:47 PM, Mateusz Kowalczyk
<fuuzetsu at fuuzetsu.co.uk> wrote:
> I thought that KC was asking why is 0.5 not displayed as 0.5 when it's
> supported by the IEEE754. Even if that wasn't question, it is my
> question now.
>
> IEEE754 is capable of representing 0.5 with perfect precision; in fact,
> it would be `00111111000000000000000000000000'.
>
> My question is why [0.1, 0.2 .. 1.0] comes up with an imprecise
> midpoint:
> [0.1,0.2,0.30000000000000004,0.4000000000000001,0.5000000000000001,0.6000000000000001,0.7000000000000001,0.8,0.9,1.0]
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners



-- 
--
Regards,
KC



More information about the Beginners mailing list