Go to the first, previous, next, last section, table of contents.

Operations on/for `Integers' (interface to GMP)

We implement `Integers' (arbitrary-precision integers) using the GNU multiple-precision (GMP) package (version 1.3.2). Note: some of this might change when we upgrade to using GMP 2.x. The data type for `Integer' must mirror that for `MP_INT' in `gmp.h' (see `gmp.info' in `ghc/includes/runtime/gmp'). It comes out as:
data Integer = J# Int# Int# ByteArray#
So, `Integer' is really just a "pairing" type for a particular collection of primitive types. The operations in the GMP return other combinations of GMP-plus-something, so we need "pairing" types for those, too:
data Return2GMPs     = Return2GMPs Int# Int# ByteArray# Int# Int# ByteArray#
data ReturnIntAndGMP = ReturnIntAndGMP Int# Int# Int# ByteArray#

-- ????? something to return a string of bytes (in the heap?)
The primitive ops to support `Integers' use the "pieces" of the representation, and are as follows:
negateInteger#  :: Int# -> Int# -> ByteArray# -> Integer

{plus,minus,times}Integer# :: Int# -> Int# -> ByteArray#
                           -> Int# -> Int# -> ByteArray#
                           -> Integer

cmpInteger# :: Int# -> Int# -> ByteArray#
            -> Int# -> Int# -> ByteArray#
            -> Int# -- -1 for <; 0 for ==; +1 for >

divModInteger#, quotRemInteger#
        :: Int# -> Int# -> ByteArray#
        -> Int# -> Int# -> ByteArray#
        -> PrelNum.Return2GMPs

integer2Int# :: Int# -> Int# -> ByteArray# -> Int# 

int2Integer#  :: Int#  -> Integer -- NB: no error-checking on these two!
word2Integer# :: Word# -> Integer

addr2Integer# :: Addr# -> Integer
        -- the Addr# is taken to be a `char *' string
        -- to be converted into an Integer.

Go to the first, previous, next, last section, table of contents.