[Haskell-cafe] Confused by ghci output
Claude Heiland-Allen
claude at goto10.org
Thu May 31 18:49:42 CEST 2012
Hi Clark,
ghci is defaulting to Integer
modexp2 forces Int
Int overflows with 3^40
On 31/05/12 17:35, Clark Gaebel wrote:
> *X> 3^40 `mod` 3 == modexp2 3 40 3
> False
*X> fromInteger (3^40 `mod` 3) == modexp2 3 40 3
True
> *X> modexp2 3 40 3
> 0
> *X> 3^40 `mod` 3
> 0
*X> 3^40 `mod` 3 ::Int
2
> I'm confused. Last I checked, 0 == 0.
Int overflow is ugly!
*X> 3^40
12157665459056928801
*X> maxBound :: Int
9223372036854775807
Claude
>
> Using GHC 7.4.1, and the file x.hs (which has been loaded in ghci) can be
> found here: http://hpaste.org/69342
>
> I noticed this after prop_sanemodexp was failing.
>
> Any help would be appreciated,
> - Clark
>
>
>
>
> _______________________________________________
> 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