[Haskell-cafe] Strange behavior of float literals

David Benbennick dbenbenn at gmail.com
Sat Apr 5 04:46:23 EDT 2008

On Sat, Apr 5, 2008 at 1:00 AM, Vladimir Reshetnikov
<v.reshetnikov at gmail.com> 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?

Sounds like a bug to me.  I wasn't able to test your example in GHCi
because it started consuming all my memory.  In GHCi 6.8.2 I got:

Prelude> let x = 1e-1000000
*** Exception: stack overflow

I tried compiling the following program with "ghc -O --make", and it
again started consuming all memory:

x = 1e-100000000 :: Double
main = print x

>  What it the correct place to submit bug reports concerning GHC?


I'm doing Science and I'm still alive.

More information about the Haskell-Cafe mailing list