-- We can't throw an error here, so it is up to our caller to-- not call us with both arguments being 0.{-# NOINLINE gcdInteger #-}gcdInteger::Integer->Integer->Integer-- SUP: Do we really need the first two cases?gcdIntegera@(S#INT_MINBOUND)b=gcdInteger(toBiga)bgcdIntegerab@(S#INT_MINBOUND)=gcdIntegera(toBigb)gcdInteger(S#a)(S#b)=S#(gcdIntab)gcdIntegeria@(S#a)ib@(J#sbb)=ifa==#0#thenabsIntegeribelseifsb==#0#thenabsIntegeriaelseS#(gcdIntegerInt#absSbbabsA)where!absA=ifa<#0#thennegateInt#aelsea!absSb=ifsb<#0#thennegateInt#sbelsesbgcdIntegeria@(J#__)ib@(S#_)=gcdIntegeribiagcdInteger(J#saa)(J#sbb)=casegcdInteger#saasbbof(#sg,g#)->J#sgg{-# NOINLINE lcmInteger #-}lcmInteger::Integer->Integer->IntegerlcmIntegerab=ifa`eqInteger`S#0#thenS#0#elseifb`eqInteger`S#0#thenS#0#else(divExactaa(gcdIntegeraaab))`timesInteger`abwhereaa=absIntegeraab=absIntegerb{-# RULES "gcdInteger/Int" forall a b.
gcdInteger (S# a) (S# b) = S# (gcdInt a b)
#-}gcdInt::Int#->Int#->Int#gcdInt0#y=absIntygcdIntx0#=absIntxgcdIntxy=gcdInt#(absIntx)(absInty)absInt::Int#->Int#absIntx=ifx<#0#thennegateInt#xelsexdivExact::Integer->Integer->IntegerdivExacta@(S#INT_MINBOUND)b=divExact(toBiga)bdivExact(S#a)(S#b)=S#(quotInt#ab)divExact(S#a)(J#sbb)=S#(quotInt#a(integer2Int#sbb))divExact(J#saa)(S#b)=caseint2Integer#bof(#sb,b'#)->casedivExactInteger#saasbb'of(#sd,d#)->J#sdddivExact(J#saa)(J#sbb)=casedivExactInteger#saasbbof(#sd,d#)->J#sdd

\end{code}
%*********************************************************
%* *
\subsection{The @Integer@ Bit definitions@}
%* *
%*********************************************************
We explicitly pattern match against J# and S# in order to produce
Core that doesn't have pattern matching errors, as that would
introduce a spurious dependency to base.
\begin{code}

-- This is used by hashUnique-- | hashInteger returns the same value as 'fromIntegral', although in-- unboxed form. It might be a reasonable hash function for 'Integer', -- given a suitable distribution of 'Integer' values.hashInteger::Integer->Int#hashInteger=integerToInt