Integers to Ints

Rijk-Jan van Haaften rjchaaft@cs.uu.nl
Wed, 16 May 2001 12:54:12 +0200


Hello,

>Can someone explain the following behaviour? Or is it a bug in hugs?

I can not explain it. Rather strange is that even this is allowed:
(fromIntegral (toInteger (minBound::Int) + 1) -1) :: Int
yielding
-2147483648

> > (fromIntegral(toInteger(minBound::Int))::Int)
>
>Program error: {primIntegerToInt (-2147483648)}
>(15 reductions, 70 cells)
>
> > (fromIntegral(toInteger((minBound::Int)+1))::Int)
>-2147483647
>(21 reductions, 29 cells)
>
> > minBound::Int
>-2147483648
>(9 reductions, 19 cells)