Hi Clark,

On Thu, May 31, 2012 at 10:35 AM, Clark Gaebel <[email protected]> wrote:

> *X> 3^40 `mod` 3 == modexp2 3 40 3
> False
> *X> modexp2 3 40 3
> 0
> *X> 3^40 `mod` 3
> 0
>
> I'm confused. Last I checked, 0 == 0.
>

Your HPaste shows the type of modexp2 is Int -> Int -> Int -> Int, so ghci
will infer that (3^40) is an Int. But an Int isn't big enough to hold 3^40.

Prelude> 3^40 :: Int
-6289078614652622815
Prelude> (3^40 :: Int) `mod` 3
2

Kevin
-- 
Kevin Charter
[email protected]
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to