-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Integer library based on GMP
°5u
°5uInteger library based on GMP
@package integer-gmp
@version 1.0.1.0

module GHC.Integer.Logarithms

-- | Compute base-2 log of <a>Word#</a>
°5u
°5uThis is internally implemented as count-leading-zeros machine
°5uinstruction.
wordLog2# :: Word# -> Int#

-- | Calculate the integer base 2 logarithm of an <a>Integer</a>. The
°5ucalculation is more efficient than for the general case, on platforms
°5uwith 32- or 64-bit words much more efficient.
°5u
°5uThe argument must be strictly positive, that condition is <i>not</i>
°5uchecked.
integerLog2# :: Integer -> Int#

-- | Calculate the integer logarithm for an arbitrary base.
°5u
°5uThe base must be greater than <tt>1</tt>, the second argument, the
°5unumber whose logarithm is sought, shall be positive, otherwise the
°5uresult is meaningless.
°5u
°5uThe following property holds
°5u
°5u<pre>
°5ubase ^ <a>integerLogBase#</a> base m &lt;= m &lt; base ^(<a>integerLogBase#</a> base m + 1)
°5u</pre>
°5u
°5ufor <tt>base &gt; 1</tt> and <tt>m &gt; 0</tt>.
°5u
°5uNote: Internally uses <a>integerLog2#</a> for base 2
integerLogBase# :: Integer -> Integer -> Int#


-- | The <a>Integer</a> type.
°5u
°5uThis module exposes the <i>portable</i> <a>Integer</a> API. See
°5u<a>GHC.Integer.GMP.Internals</a> for the <tt>integer-gmp</tt>-specific
°5uinternal representation of <a>Integer</a> as well as optimized
°5uGMP-specific operations.
module GHC.Integer

-- | Invariant: <a>Jn#</a> and <a>Jp#</a> are used iff value doesn't fit in
°5u<a>S#</a>
°5u
°5uUseful properties resulting from the invariants:
°5u
°5u<ul>
°5u<li><pre>abs (<a>S#</a> _) &lt;= abs (<a>Jp#</a> _)</pre></li>
°5u<li><pre>abs (<a>S#</a> _) &lt; abs (<a>Jn#</a> _)</pre></li>
°5u</ul>
data Integer

-- | Construct <a>Integer</a> value from list of <a>Int</a>s.
°5u
°5uThis function is used by GHC for constructing <a>Integer</a> literals.
mkInteger :: Bool -> [Int] -> Integer

-- | Should rather be called <tt>intToInteger</tt>
smallInteger :: Int# -> Integer
wordToInteger :: Word# -> Integer
integerToWord :: Integer -> Word#

-- | Truncates <a>Integer</a> to least-significant <a>Int#</a>
integerToInt :: Integer -> Int#
encodeFloatInteger :: Integer -> Int# -> Float#
floatFromInteger :: Integer -> Float#
encodeDoubleInteger :: Integer -> Int# -> Double#
decodeDoubleInteger :: Double# -> (# Integer, Int# #)
doubleFromInteger :: Integer -> Double#

-- | Add two <a>Integer</a>s
plusInteger :: Integer -> Integer -> Integer

-- | Subtract one <a>Integer</a> from another.
minusInteger :: Integer -> Integer -> Integer

-- | Multiply two <a>Integer</a>s
timesInteger :: Integer -> Integer -> Integer

-- | Negate <a>Integer</a>
negateInteger :: Integer -> Integer

-- | Compute absolute value of an <a>Integer</a>
absInteger :: Integer -> Integer

-- | Return <tt>-1</tt>, <tt>0</tt>, and <tt>1</tt> depending on whether
°5uargument is negative, zero, or positive, respectively
signumInteger :: Integer -> Integer

-- | Simultaneous <a>divInteger</a> and <a>modInteger</a>.
°5u
°5uDivisor must be non-zero otherwise the GHC runtime will terminate with
°5ua division-by-zero fault.
divModInteger :: Integer -> Integer -> (# Integer, Integer #)
divInteger :: Integer -> Integer -> Integer
modInteger :: Integer -> Integer -> Integer

-- | Simultaneous <a>quotInteger</a> and <a>remInteger</a>.
°5u
°5uDivisor must be non-zero otherwise the GHC runtime will terminate with
°5ua division-by-zero fault.
quotRemInteger :: Integer -> Integer -> (# Integer, Integer #)
quotInteger :: Integer -> Integer -> Integer
remInteger :: Integer -> Integer -> Integer
eqInteger :: Integer -> Integer -> Bool

-- | Not-equal predicate.
neqInteger :: Integer -> Integer -> Bool
leInteger :: Integer -> Integer -> Bool
gtInteger :: Integer -> Integer -> Bool
ltInteger :: Integer -> Integer -> Bool
geInteger :: Integer -> Integer -> Bool
compareInteger :: Integer -> Integer -> Ordering
eqInteger# :: Integer -> Integer -> Int#
neqInteger# :: Integer -> Integer -> Int#
leInteger# :: Integer -> Integer -> Int#
gtInteger# :: Integer -> Integer -> Int#
ltInteger# :: Integer -> Integer -> Int#
geInteger# :: Integer -> Integer -> Int#

-- | Bitwise AND operation
andInteger :: Integer -> Integer -> Integer

-- | Bitwise OR operation
orInteger :: Integer -> Integer -> Integer

-- | Bitwise XOR operation
xorInteger :: Integer -> Integer -> Integer

-- | Bitwise <tt>NOT</tt> operation
complementInteger :: Integer -> Integer

-- | Shift-left operation
°5u
°5uEven though the shift-amount is expressed as <a>Int#</a>, the result
°5uis undefined for negative shift-amounts.
shiftLInteger :: Integer -> Int# -> Integer

-- | Arithmetic shift-right operation
°5u
°5uEven though the shift-amount is expressed as <a>Int#</a>, the result
°5uis undefined for negative shift-amounts.
shiftRInteger :: Integer -> Int# -> Integer

-- | Test if <i>n</i>-th bit is set.
testBitInteger :: Integer -> Int# -> Bool
hashInteger :: Integer -> Int#


-- | This modules provides access to the <a>Integer</a> constructors and
°5uexposes some highly optimized GMP-operations.
°5u
°5uNote that since <tt>integer-gmp</tt> does not depend on <tt>base</tt>,
°5uerror reporting via exceptions, <tt>error</tt>, or <tt>undefined</tt>
°5uis not available. Instead, the low-level functions will crash the
°5uruntime if called with invalid arguments.
°5u
°5uSee also <a>GHC Commentary: Libraries/Integer</a>.
module GHC.Integer.GMP.Internals

-- | Invariant: <a>Jn#</a> and <a>Jp#</a> are used iff value doesn't fit in
°5u<a>S#</a>
°5u
°5uUseful properties resulting from the invariants:
°5u
°5u<ul>
°5u<li><pre>abs (<a>S#</a> _) &lt;= abs (<a>Jp#</a> _)</pre></li>
°5u<li><pre>abs (<a>S#</a> _) &lt; abs (<a>Jn#</a> _)</pre></li>
°5u</ul>
data Integer

-- | iff value in <tt>[minBound::<a>Int</a>, maxBound::<a>Int</a>]</tt>
°5urange
S# :: !Int# -> Integer

-- | iff value in <tt>]maxBound::<a>Int</a>, +inf[</tt> range
Jp# :: {-# UNPACK #-} !BigNat -> Integer

-- | iff value in <tt>]-inf, minBound::<a>Int</a>[</tt> range
Jn# :: {-# UNPACK #-} !BigNat -> Integer

-- | Test whether all internal invariants are satisfied by <a>Integer</a>
°5uvalue
°5u
°5uReturns <tt>1#</tt> if valid, <tt>0#</tt> otherwise.
°5u
°5uThis operation is mostly useful for test-suites and/or code which
°5uconstructs <a>Integer</a> values directly.
isValidInteger# :: Integer -> Int#

-- | <a>Integer</a> for which only <i>n</i>-th bit is set. Undefined
°5ubehaviour for negative <i>n</i> values.
bitInteger :: Int# -> Integer

-- | Count number of set bits. For negative arguments returns negative
°5upopulation count of negated argument.
popCountInteger :: Integer -> Int#

-- | Compute greatest common divisor.
gcdInteger :: Integer -> Integer -> Integer

-- | Extended euclidean algorithm.
°5u
°5uFor <tt><i>a</i></tt> and <tt><i>b</i></tt>, compute their greatest
°5ucommon divisor <tt><i>g</i></tt> and the coefficient <tt><i>s</i></tt>
°5usatisfying <tt><i>a</i><i>s</i> + <i>b</i><i>t</i> = <i>g</i></tt>.
gcdExtInteger :: Integer -> Integer -> (# Integer, Integer #)

-- | Compute least common multiple.
lcmInteger :: Integer -> Integer -> Integer

-- | Square <a>Integer</a>
sqrInteger :: Integer -> Integer

-- | "<tt><a>powModInteger</a> <i>b</i> <i>e</i> <i>m</i></tt>" computes
°5ubase <tt><i>b</i></tt> raised to exponent <tt><i>e</i></tt> modulo
°5u<tt>abs(<i>m</i>)</tt>.
°5u
°5uNegative exponents are supported if an inverse modulo
°5u<tt><i>m</i></tt> exists.
°5u
°5u<b>Warning</b>: It's advised to avoid calling this primitive with
°5unegative exponents unless it is guaranteed the inverse exists, as
°5ufailure to do so will likely cause program abortion due to a
°5udivide-by-zero fault. See also <a>recipModInteger</a>.
°5u
°5uFuture versions of <tt>integer_gmp</tt> may not support negative
°5u<tt><i>e</i></tt> values anymore.
powModInteger :: Integer -> Integer -> Integer -> Integer

-- | "<tt><a>powModSecInteger</a> <i>b</i> <i>e</i> <i>m</i></tt>" computes
°5ubase <tt><i>b</i></tt> raised to exponent <tt><i>e</i></tt> modulo
°5u<tt><i>m</i></tt>. It is required that <tt><i>e</i> &gt;= 0</tt> and
°5u<tt><i>m</i></tt> is odd.
°5u
°5uThis is a "secure" variant of <a>powModInteger</a> using the
°5u<tt>mpz_powm_sec()</tt> function which is designed to be resilient to
°5uside channel attacks and is therefore intended for cryptographic
°5uapplications.
°5u
°5uThis primitive is only available when the underlying GMP library
°5usupports it (GMP &gt;= 5). Otherwise, it internally falls back to
°5u<tt><a>powModInteger</a></tt>, and a warning will be emitted when
°5uused.
°5u
°5u@since TODO
powModSecInteger :: Integer -> Integer -> Integer -> Integer

-- | "<tt><a>recipModInteger</a> <i>x</i> <i>m</i></tt>" computes the
°5uinverse of <tt><i>x</i></tt> modulo <tt><i>m</i></tt>. If the inverse
°5uexists, the return value <tt><i>y</i></tt> will satisfy <tt>0 &lt;
°5u<i>y</i> &lt; abs(<i>m</i>)</tt>, otherwise the result is <tt>0</tt>.
recipModInteger :: Integer -> Integer -> Integer
wordToNegInteger :: Word# -> Integer
bigNatToInteger :: BigNat -> Integer
bigNatToNegInteger :: BigNat -> Integer

-- | Type representing <i>raw</i> arbitrary-precision Naturals
°5u
°5uThis is common type used by <tt>Natural</tt> and <a>Integer</a>. As
°5uthis type consists of a single constructor wrapping a
°5u<a>ByteArray#</a> it can be unpacked.
°5u
°5uEssential invariants:
°5u
°5u<ul>
°5u<li><a>ByteArray#</a> size is an exact multiple of <a>Word#</a>
°5usize</li>
°5u<li>limbs are stored in least-significant-limb-first order,</li>
°5u<li>the most-significant limb must be non-zero, except for</li>
°5u<li><tt>0</tt> which is represented as a 1-limb.</li>
°5u</ul>
data BigNat
BN# :: ByteArray# -> BigNat

-- | Type representing a GMP Limb
type GmpLimb = Word
type GmpLimb# = Word#

-- | Count of <a>GmpLimb</a>s, must be positive (unless specified
°5uotherwise).
type GmpSize = Int
type GmpSize# = Int#

-- | Test whether all internal invariants are satisfied by <a>BigNat</a>
°5uvalue
°5u
°5uReturns <tt>1#</tt> if valid, <tt>0#</tt> otherwise.
°5u
°5uThis operation is mostly useful for test-suites and/or code which
°5uconstructs <a>Integer</a> values directly.
isValidBigNat# :: BigNat -> Int#

-- | Return number of limbs contained in <a>BigNat</a>.
sizeofBigNat# :: BigNat -> GmpSize#

-- | CAF representing the value <tt>0 :: BigNat</tt>
zeroBigNat :: BigNat

-- | CAF representing the value <tt>1 :: BigNat</tt>
oneBigNat :: BigNat

-- | Special 0-sized bigNat returned in case of arithmetic underflow
°5u
°5uThis is currently only returned by the following operations:
°5u
°5u<ul>
°5u<li><a>minusBigNat</a></li>
°5u<li><a>minusBigNatWord</a></li>
°5u</ul>
°5u
°5uOther operations such as <a>quotBigNat</a> may return
°5u<a>nullBigNat</a> as well as a dummy/place-holder value instead of
°5u<tt>undefined</tt> since we can't throw exceptions. But that behaviour
°5ushould not be relied upon.
°5u
°5uNB: <tt>isValidBigNat# nullBigNat</tt> is false
nullBigNat :: BigNat

-- | Construct <a>BigNat</a> from existing <a>ByteArray#</a> containing
°5u<i>n</i> <a>GmpLimb</a>s in least-significant-first order.
°5u
°5uIf possible <a>ByteArray#</a>, will be used directly (i.e. shared
°5u<i>without</i> cloning the <a>ByteArray#</a> into a newly allocated
°5uone)
°5u
°5uNote: size parameter (times <tt>sizeof(GmpLimb)</tt>) must be less or
°5uequal to its <a>sizeofByteArray#</a>.
byteArrayToBigNat# :: ByteArray# -> GmpSize# -> BigNat

-- | Construct 1-limb <a>BigNat</a> from <a>Word#</a>
wordToBigNat :: Word# -> BigNat

-- | Construct BigNat from 2 limbs. The first argument is the
°5umost-significant limb.
wordToBigNat2 :: Word# -> Word# -> BigNat

-- | Equivalent to <tt><a>word2Int#</a> . <a>bigNatToWord</a></tt>
bigNatToInt :: BigNat -> Int#

-- | Same as <tt><a>indexBigNat#</a> bn 0#</tt>
bigNatToWord :: BigNat -> Word#

-- | Extract <i>n</i>-th (0-based) limb in <a>BigNat</a>. <i>n</i> must be
°5uless than size as reported by <a>sizeofBigNat#</a>.
indexBigNat# :: BigNat -> GmpSize# -> GmpLimb#
plusBigNat :: BigNat -> BigNat -> BigNat
plusBigNatWord :: BigNat -> GmpLimb# -> BigNat

-- | Returns <a>nullBigNat</a> (see <a>isNullBigNat#</a>) in case of
°5uunderflow
minusBigNat :: BigNat -> BigNat -> BigNat

-- | Returns <a>nullBigNat</a> (see <a>isNullBigNat#</a>) in case of
°5uunderflow
minusBigNatWord :: BigNat -> GmpLimb# -> BigNat
timesBigNat :: BigNat -> BigNat -> BigNat
timesBigNatWord :: BigNat -> GmpLimb# -> BigNat

-- | Square <a>BigNat</a>
sqrBigNat :: BigNat -> BigNat

-- | If divisor is zero, <tt>(# <a>nullBigNat</a>, <a>nullBigNat</a>
°5u#)</tt> is returned
quotRemBigNat :: BigNat -> BigNat -> (# BigNat, BigNat #)

-- | Note: Result of div/0 undefined
quotRemBigNatWord :: BigNat -> GmpLimb# -> (# BigNat, GmpLimb# #)
quotBigNatWord :: BigNat -> GmpLimb# -> BigNat
quotBigNat :: BigNat -> BigNat -> BigNat
remBigNat :: BigNat -> BigNat -> BigNat

-- | div/0 not checked
remBigNatWord :: BigNat -> GmpLimb# -> Word#
gcdBigNat :: BigNat -> BigNat -> BigNat
gcdBigNatWord :: BigNat -> Word# -> Word#

-- | Version of <a>powModInteger</a> operating on <a>BigNat</a>s
powModBigNat :: BigNat -> BigNat -> BigNat -> BigNat

-- | Version of <a>powModInteger</a> for <a>Word#</a>-sized moduli
powModBigNatWord :: BigNat -> BigNat -> GmpLimb# -> GmpLimb#

-- | Version of <a>recipModInteger</a> operating on <a>BigNat</a>s
recipModBigNat :: BigNat -> BigNat -> BigNat
shiftRBigNat :: BigNat -> Int# -> BigNat
shiftLBigNat :: BigNat -> Int# -> BigNat
testBitBigNat :: BigNat -> Int# -> Bool
clearBitBigNat :: BigNat -> Int# -> BigNat
complementBitBigNat :: BigNat -> Int# -> BigNat
setBitBigNat :: BigNat -> Int# -> BigNat
andBigNat :: BigNat -> BigNat -> BigNat
xorBigNat :: BigNat -> BigNat -> BigNat
popCountBigNat :: BigNat -> Int#
orBigNat :: BigNat -> BigNat -> BigNat

-- | Specialised version of
°5u
°5u<pre>
°5ubitBigNat = shiftLBigNat (wordToBigNat 1##)
°5u</pre>
°5u
°5uavoiding a few redundant allocations
bitBigNat :: Int# -> BigNat

-- | Test if <a>BigNat</a> value is equal to zero.
isZeroBigNat :: BigNat -> Bool

-- | Test for special 0-sized <a>BigNat</a> representing underflows.
isNullBigNat# :: BigNat -> Int#
compareBigNatWord :: BigNat -> GmpLimb# -> Ordering
compareBigNat :: BigNat -> BigNat -> Ordering
eqBigNatWord :: BigNat -> GmpLimb# -> Bool
eqBigNatWord# :: BigNat -> GmpLimb# -> Int#
eqBigNat :: BigNat -> BigNat -> Bool
eqBigNat# :: BigNat -> BigNat -> Int#
gtBigNatWord# :: BigNat -> GmpLimb# -> Int#

-- | Compute greatest common divisor.
°5u
°5u<b>Warning</b>: result may become negative if (at least) one argument
°5uis <tt>minBound</tt>
gcdInt :: Int# -> Int# -> Int#

-- | Compute greatest common divisor.
gcdWord :: Word# -> Word# -> Word#

-- | Version of <a>powModInteger</a> operating on <a>Word#</a>s
powModWord :: GmpLimb# -> GmpLimb# -> GmpLimb# -> GmpLimb#

-- | Version of <a>recipModInteger</a> operating on <a>Word#</a>s
recipModWord :: GmpLimb# -> GmpLimb# -> GmpLimb#

-- | Probalistic Miller-Rabin primality test.
°5u
°5u"<tt><a>testPrimeInteger</a> <i>n</i> <i>k</i></tt>" determines
°5uwhether <tt><i>n</i></tt> is prime and returns one of the following
°5uresults:
°5u
°5u<ul>
°5u<li><tt>2#</tt> is returned if <tt><i>n</i></tt> is definitely
°5uprime,</li>
°5u<li><tt>1#</tt> if <tt><i>n</i></tt> is a <i>probable prime</i>,
°5uor</li>
°5u<li><tt>0#</tt> if <tt><i>n</i></tt> is definitely not a prime.</li>
°5u</ul>
°5u
°5uThe <tt><i>k</i></tt> argument controls how many test rounds are
°5uperformed for determining a <i>probable prime</i>. For more details,
°5usee <a>GMP documentation for `mpz_probab_prime_p()`</a>.
testPrimeInteger :: Integer -> Int# -> Int#

-- | Version of <a>testPrimeInteger</a> operating on <a>BigNat</a>s
testPrimeBigNat :: BigNat -> Int# -> Int#

-- | Version of <a>testPrimeInteger</a> operating on <a>Word#</a>s
testPrimeWord# :: GmpLimb# -> Int# -> Int#

-- | Compute next prime greater than <tt><i>n</i></tt> probalistically.
°5u
°5uAccording to the GMP documentation, the underlying function
°5u<tt>mpz_nextprime()</tt> "uses a probabilistic algorithm to identify
°5uprimes. For practical purposes it's adequate, the chance of a
°5ucomposite passing will be extremely small."
nextPrimeInteger :: Integer -> Integer

-- | Version of <tt>nextPrimeInteger</tt> operating on <a>BigNat</a>s
nextPrimeBigNat :: BigNat -> BigNat

-- | Version of <a>nextPrimeInteger</a> operating on <a>Word#</a>s
nextPrimeWord# :: GmpLimb# -> GmpLimb#

-- | Version of <a>sizeInBaseInteger</a> operating on <a>BigNat</a>
sizeInBaseBigNat :: BigNat -> Int# -> Word#

-- | Compute number of digits (without sign) in given <tt><i>base</i></tt>.
°5u
°5uThis function wraps <tt>mpz_sizeinbase()</tt> which has some
°5uimplementation pecularities to take into account:
°5u
°5u<ul>
°5u<li>"<tt><a>sizeInBaseInteger</a> 0 <i>base</i> = 1</tt>" (see also
°5ucomment in <a>exportIntegerToMutableByteArray</a>).</li>
°5u<li>This function is only defined if <tt><i>base</i> &gt;= 2#</tt> and
°5u<tt><i>base</i> &lt;= 256#</tt> (Note: the documentation claims that
°5uonly <tt><i>base</i> &lt;= 62#</tt> is supported, however the actual
°5uimplementation supports up to base 256).</li>
°5u<li>If <tt><i>base</i></tt> is a power of 2, the result will be exact.
°5uIn other cases (e.g. for <tt><i>base</i> = 10#</tt>), the result
°5u<i>may</i> be 1 digit too large sometimes.</li>
°5u<li>"<tt><a>sizeInBaseInteger</a> <i>i</i> 2#</tt>" can be used to
°5udetermine the most significant bit of <tt><i>i</i></tt>.</li>
°5u</ul>
sizeInBaseInteger :: Integer -> Int# -> Word#

-- | Version of <a>sizeInBaseInteger</a> operating on <a>Word#</a>
sizeInBaseWord# :: Word# -> Int# -> Word#

-- | Version of <a>exportIntegerToAddr</a> operating on <a>BigNat</a>s.
exportBigNatToAddr :: BigNat -> Addr# -> Int# -> IO Word

-- | Dump <a>Integer</a> (without sign) to <tt><i>addr</i></tt> in base-256
°5urepresentation.
°5u
°5u<pre>
°5u<a>exportIntegerToAddr</a> <i>i</i> <i>addr</i> <i>e</i>
°5u</pre>
°5u
°5uSee description of <a>exportIntegerToMutableByteArray</a> for more
°5udetails.
exportIntegerToAddr :: Integer -> Addr# -> Int# -> IO Word

-- | Version of <a>exportIntegerToAddr</a> operating on <a>Word</a>s.
exportWordToAddr :: Word -> Addr# -> Int# -> IO Word

-- | Version of <a>exportIntegerToMutableByteArray</a> operating on
°5u<a>BigNat</a>s.
exportBigNatToMutableByteArray :: BigNat -> MutableByteArray# RealWorld -> Word# -> Int# -> IO Word

-- | Dump <a>Integer</a> (without sign) to mutable byte-array in base-256
°5urepresentation.
°5u
°5uThe call
°5u
°5u<pre>
°5u<a>exportIntegerToMutableByteArray</a> <i>i</i> <i>mba</i> <i>offset</i> <i>msbf</i>
°5u</pre>
°5u
°5uwrites
°5u
°5u<ul>
°5u<li>the <a>Integer</a> <tt><i>i</i></tt></li>
°5u<li>into the <a>MutableByteArray#</a> <tt><i>mba</i></tt> starting at
°5u<tt><i>offset</i></tt></li>
°5u<li>with most significant byte first if <tt>msbf</tt> is <tt>1#</tt>
°5uor least significant byte first if <tt>msbf</tt> is <tt>0#</tt>,
°5uand</li>
°5u<li>returns number of bytes written.</li>
°5u</ul>
°5u
°5uUse "<tt><a>sizeInBaseInteger</a> <i>i</i> 256#</tt>" to compute the
°5uexact number of bytes written in advance for <tt><i>i</i> /= 0</tt>.
°5uIn case of <tt><i>i</i> == 0</tt>,
°5u<a>exportIntegerToMutableByteArray</a> will write and report zero
°5ubytes written, whereas <a>sizeInBaseInteger</a> report one byte.
°5u
°5uIt's recommended to avoid calling
°5u<a>exportIntegerToMutableByteArray</a> for small integers as this
°5ufunction would currently convert those to big integers in msbf to call
°5u<tt>mpz_export()</tt>.
exportIntegerToMutableByteArray :: Integer -> MutableByteArray# RealWorld -> Word# -> Int# -> IO Word

-- | Version of <a>exportIntegerToMutableByteArray</a> operating on
°5u<a>Word</a>s.
exportWordToMutableByteArray :: Word -> MutableByteArray# RealWorld -> Word# -> Int# -> IO Word

-- | Version of <a>importIntegerFromAddr</a> constructing a <a>BigNat</a>
importBigNatFromAddr :: Addr# -> Word# -> Int# -> IO BigNat

-- | Read <a>Integer</a> (without sign) from memory location at
°5u<tt><i>addr</i></tt> in base-256 representation.
°5u
°5u<pre>
°5u<a>importIntegerFromAddr</a> <i>addr</i> <i>size</i> <i>msbf</i>
°5u</pre>
°5u
°5uSee description of <a>importIntegerFromByteArray</a> for more details.
importIntegerFromAddr :: Addr# -> Word# -> Int# -> IO Integer

-- | Version of <a>importIntegerFromByteArray</a> constructing a
°5u<a>BigNat</a>
importBigNatFromByteArray :: ByteArray# -> Word# -> Word# -> Int# -> BigNat

-- | Read <a>Integer</a> (without sign) from byte-array in base-256
°5urepresentation.
°5u
°5uThe call
°5u
°5u<pre>
°5u<a>importIntegerFromByteArray</a> <i>ba</i> <i>offset</i> <i>size</i> <i>msbf</i>
°5u</pre>
°5u
°5ureads
°5u
°5u<ul>
°5u<li><tt><i>size</i></tt> bytes from the <a>ByteArray#</a>
°5u<tt><i>ba</i></tt> starting at <tt><i>offset</i></tt></li>
°5u<li>with most significant byte first if <tt><i>msbf</i></tt> is
°5u<tt>1#</tt> or least significant byte first if <tt><i>msbf</i></tt> is
°5u<tt>0#</tt>, and</li>
°5u<li>returns a new <a>Integer</a></li>
°5u</ul>
importIntegerFromByteArray :: ByteArray# -> Word# -> Word# -> Int# -> Integer
