6 ms·
That’s floating point, though. Not Double. Floating point has the same gotchas in all languages because it is a defined standard.
by jose_zap 1y ago
That’s floating point, though. Not Double. Floating point has the same gotchas in all languages because it is a defined standard.
- tromp 1y agoThat 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.