[Haskell-cafe] Strange behavior of float literals

Miguel Mitrofanov miguelimo38 at yandex.ru
Sat Apr 5 04:58:24 EDT 2008


I don't know if it is a bug, but

100000000000000000000000000000000000000000000 = 0 (mod 2^32),

so, if GHC considers exponent as Int (not Integer), then it's the same  
as 1e0 = 1. In the same way,

999999999999999999999999999999999999999999999 = -1 (mod 2^32),

and 1e-(-1) = 1e1 = 10.

Note also that the function "exponent" from the RealFloat class has  
the type

exponent :: a -> Int

On 5 Apr 2008, at 12:00, Vladimir Reshetnikov wrote:
> The float literal 1e-100000000000000000000000000000000000000000000 in
> GHC evaluates to 1.0, and
> 1e-999999999999999999999999999999999999999999999 evaluates to 10.0.
> Is it a bug, or a documented overflow behavior?
>
> What it the correct place to submit bug reports concerning GHC?
> -- 
> Thank you,
>
> Vladimir Reshetnikov (aka nikov),
> Microsoft MVP
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list