[Haskell-cafe] Confused by ghci output

Sean Leather leather at cs.uu.nl
Thu May 31 18:53:33 CEST 2012


On Thu, May 31, 2012 at 6:35 PM, Clark Gaebel wrote:

> *X> 3^40 `mod` 3 == modexp2 3 40 3
> False
> *X> modexp2 3 40 3
> 0
> *X> 3^40 `mod` 3
> 0
>

*X> 3^40 `mod` 3 :: Int
1
*X> 3^40 `mod` 3 :: Integer
0

I'm confused. Last I checked, 0 == 0.
>

Yes, but 3^40 /= 3^40 when you have arithmetic overflow:

*X> 3^40 :: Int
689956897
*X> 3^40 :: Integer
12157665459056928801

Regards,
Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120531/8e0bc9c7/attachment.htm>


More information about the Haskell-Cafe mailing list