erikwiffin / 0.30000000000000004

Floating Point Math Examples

Home Page:https://0.30000000000000004.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Note on GHC

sternenseemann opened this issue · comments

Using Double triggers the Problem in GHC, Float works fine (could be a precision reason, though):

Prelude> 0.2 + 0.1 :: Double
0.30000000000000004
Prelude> 0.2 + 0.1 :: Float 
0.3

If you send me a PR fixing this I'd be happy to merge it.

This too general actually, applies for almost every language that has 32-bit and 64-bit floating points. Gotta add a note on exact-real though, which allows for truly precise floating point operations.

Gonna do that sometime soon™