[Haskell-cafe] Bug with [Double]

Lutz Donnerhacke lutz at iks-jena.de
Wed May 19 09:49:22 EDT 2010


* Ben Millwood wrote:
>> Prelude> [1,1+2/3..10] :: [Rational]
>> [1 % 1,5 % 3,7 % 3,3 % 1,11 % 3,13 % 3,5 % 1,17 % 3,19 % 3,7 % 1,23 %
>> 3,25 % 3,9 % 1,29 % 3,31 % 3]
>>
>> Same result.
>
> This sounds like a bug to me. The section of the Haskell Report that
> deals with the Enum class mentions Float and Double, not Rational, and
> there's really no sensible reason why Rationals would exhibit this
> behaviour given that they don't have rounding error.

Double is not better:

Prelude> [9,9+2/3..10]
[9.0,9.666666666666666,10.333333333333332]
Prelude> [7,9 .. 10]
[7,9]


More information about the Haskell-Cafe mailing list