Hi Clark,<br><br><div class="gmail_quote">On Thu, May 31, 2012 at 10:35 AM, Clark Gaebel <span dir="ltr">&lt;<a href="mailto:cgaebel@uwaterloo.ca" target="_blank">cgaebel@uwaterloo.ca</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<font face="verdana,sans-serif">*X&gt; 3^40 `mod` 3 == modexp2 3 40 3<br>False<br>*X&gt; modexp2 3 40 3<br>0<br>*X&gt; 3^40 `mod` 3<br>0<br><br>I&#39;m confused. Last I checked, 0 == 0.<br></font></blockquote><div><br></div>
<div>Your HPaste shows the type of modexp2 is Int -&gt; Int -&gt; Int -&gt; Int, so ghci will infer that (3^40) is an Int. But an Int isn&#39;t big enough to hold 3^40.</div><div><br></div><div><div>Prelude&gt; 3^40 :: Int</div>
<div>-6289078614652622815</div><div>Prelude&gt; (3^40 :: Int) `mod` 3</div><div>2</div></div><div><br></div><div>Kevin</div><div>-- </div></div>Kevin Charter<br><a href="mailto:kevin.charter@acm.org">kevin.charter@acm.org</a><br>