top | item 43756829 (no title) jose_zap | 10 months ago That’s floating point, though. Not Double. Floating point has the same gotchas in all languages because it is a defined standard. discuss order hn newest tromp|10 months ago That list is of type (Fractional a, Enum a) => [a], but ghci defaults to Doubles, as you can see from ghci> [0, 0.3 .. 2.0] :: [Float] [0.0,0.3,0.6,0.90000004,1.2,1.5,1.8000001,2.1000001] ghci> [0, 0.3 .. 2.0] :: [Double] [0.0,0.3,0.6,0.8999999999999999,1.2,1.5,1.7999999999999998,2.1] Exceeding the upper bound by 0.1 is not due to a general floating gotcha, but a specific choice in the definition of typeclass method enumFromThenTo for both Floats and Doubles.
tromp|10 months ago That list is of type (Fractional a, Enum a) => [a], but ghci defaults to Doubles, as you can see from ghci> [0, 0.3 .. 2.0] :: [Float] [0.0,0.3,0.6,0.90000004,1.2,1.5,1.8000001,2.1000001] ghci> [0, 0.3 .. 2.0] :: [Double] [0.0,0.3,0.6,0.8999999999999999,1.2,1.5,1.7999999999999998,2.1] Exceeding the upper bound by 0.1 is not due to a general floating gotcha, but a specific choice in the definition of typeclass method enumFromThenTo for both Floats and Doubles.
tromp|10 months ago