-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Integer library based on GMP -- -- This package provides the low-level implementation of the standard -- Integer type based on the GNU Multiple Precision Arithmetic -- Library (GMP). -- -- This package provides access to the internal representation of -- Integer as well as primitive operations with no proper error -- handling, and should only be used directly with the utmost care. -- -- For more details about the design of integer-gmp, see GHC -- Commentary: Libraries/Integer. @package integer-gmp -- | The Integer type. -- -- This module exposes the portable Integer API. See -- GHC.Integer.GMP.Internals for the GMP-specific internal -- representation of Integer as well as optimized GMP-specific -- operations. module GHC.Integer -- | Arbitrary-precision integers. data Integer -- | Construct Integer value from list of Ints. -- -- This function is used by GHC for constructing Integer literals. mkInteger :: Bool -> [Int] -> Integer smallInteger :: Int# -> Integer wordToInteger :: Word# -> Integer integerToWord :: Integer -> Word# integerToInt :: Integer -> Int# encodeFloatInteger :: Integer -> Int# -> Float# floatFromInteger :: Integer -> Float# encodeDoubleInteger :: Integer -> Int# -> Double# decodeDoubleInteger :: Double# -> (# Integer, Int# #) doubleFromInteger :: Integer -> Double# plusInteger :: Integer -> Integer -> Integer minusInteger :: Integer -> Integer -> Integer timesInteger :: Integer -> Integer -> Integer negateInteger :: Integer -> Integer absInteger :: Integer -> Integer signumInteger :: Integer -> Integer divModInteger :: Integer -> Integer -> (# Integer, Integer #) divInteger :: Integer -> Integer -> Integer modInteger :: Integer -> Integer -> Integer quotRemInteger :: Integer -> Integer -> (# Integer, Integer #) quotInteger :: Integer -> Integer -> Integer remInteger :: Integer -> Integer -> Integer eqInteger :: Integer -> Integer -> Bool neqInteger :: Integer -> Integer -> Bool leInteger :: Integer -> Integer -> Bool gtInteger :: Integer -> Integer -> Bool ltInteger :: Integer -> Integer -> Bool geInteger :: Integer -> Integer -> Bool compareInteger :: Integer -> Integer -> Ordering -- | Since: 0.5.1.0 eqInteger# :: Integer -> Integer -> Int# -- | Since: 0.5.1.0 neqInteger# :: Integer -> Integer -> Int# -- | Since: 0.5.1.0 leInteger# :: Integer -> Integer -> Int# -- | Since: 0.5.1.0 gtInteger# :: Integer -> Integer -> Int# -- | Since: 0.5.1.0 ltInteger# :: Integer -> Integer -> Int# -- | Since: 0.5.1.0 geInteger# :: Integer -> Integer -> Int# andInteger :: Integer -> Integer -> Integer orInteger :: Integer -> Integer -> Integer xorInteger :: Integer -> Integer -> Integer complementInteger :: Integer -> Integer shiftLInteger :: Integer -> Int# -> Integer shiftRInteger :: Integer -> Int# -> Integer -- | Since: 0.5.1.0 testBitInteger :: Integer -> Int# -> Bool -- | 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. -- -- Note: hashInteger is currently just an alias for -- integerToInt. hashInteger :: Integer -> Int# -- | This modules provides access to the Integer constructors and -- exposes some highly optimized GMP-operations. -- -- Note that since integer-gmp does not depend on base, -- error reporting via exceptions, error, or undefined -- is not available. Instead, the low-level functions will crash the -- runtime if called with invalid arguments. -- -- See also GHC Commentary: Libraries/Integer. module GHC.Integer.GMP.Internals -- | Arbitrary-precision integers. data Integer -- | "small" integers fitting into an Int# S# :: Int# -> Integer -- | "big" integers represented as GMP's mpz_t structure. -- -- The Int# field corresponds to mpz_t's -- _mp_size field, which encodes the sign and the number of -- limbs stored in the ByteArray# field (i.e. -- mpz_t's _mp_d field). Note: The ByteArray# -- may have been over-allocated, and thus larger than the size denoted by -- the Int# field. -- -- This representation tries to avoid using the GMP number representation -- for small integers that fit into a native Int#. This allows to -- reduce (or at least defer) calling into GMP for operations whose -- results remain in the Int#-domain. -- -- Note: It does not constitute a violation of invariants to -- represent an integer which would fit into an Int# with the -- J#-constructor. For instance, the value 0 has (only) -- two valid representations, either S# 0# or -- J# 0 _. J# :: Int# -> ByteArray# -> Integer -- | Compute greatest common divisor. gcdInt :: Int# -> Int# -> Int# -- | Compute greatest common divisor. gcdInteger :: Integer -> Integer -> Integer -- | Extended euclidean algorithm. -- -- For a and b, compute their greatest -- common divisor g and the coefficient s -- satisfying as + bt = g. -- -- Since: 0.5.1.0 gcdExtInteger :: Integer -> Integer -> (# Integer, Integer #) -- | Compute least common multiple. lcmInteger :: Integer -> Integer -> Integer -- | Compute next prime greater than n probalistically. -- -- According to the GMP documentation, the underlying function -- mpz_nextprime() "uses a probabilistic algorithm to identify -- primes. For practical purposes it's adequate, the chance of a -- composite passing will be extremely small." -- -- Since: 0.5.1.0 nextPrimeInteger :: Integer -> Integer -- | Probalistic Miller-Rabin primality test. -- -- "testPrimeInteger n k" determines -- whether n is prime and returns one of the following -- results: -- --
-- importIntegerFromByteArray ba offset size order ---- -- reads -- --
-- importIntegerFromAddr addr size order ---- -- See description of importIntegerFromByteArray for more details. -- -- Since: 0.5.1.0 importIntegerFromAddr :: Addr# -> Word# -> Int# -> State# s -> (# State# s, Integer #) -- | Dump Integer (without sign) to mutable byte-array in base-256 -- representation. -- -- The call -- --
-- exportIntegerToMutableByteArray i mba offset order ---- -- writes -- --
-- exportIntegerToAddr addr o e ---- -- See description of exportIntegerToMutableByteArray for more -- details. -- -- Since: 0.5.1.0 exportIntegerToAddr :: Integer -> Addr# -> Int# -> State# s -> (# State# s, Word# #) module GHC.Integer.Logarithms -- | Calculate the integer logarithm for an arbitrary base. The base must -- be greater than 1, the second argument, the number whose logarithm is -- sought, should be positive, otherwise the result is meaningless. -- --
-- base ^ integerLogBase# base m <= m < base ^ (integerLogBase# base m + 1) ---- -- for base > 1 and m > 0. integerLogBase# :: Integer -> Integer -> Int# -- | Calculate the integer base 2 logarithm of an Integer. The -- calculation is more efficient than for the general case, on platforms -- with 32- or 64-bit words much more efficient. -- -- The argument must be strictly positive, that condition is not -- checked. integerLog2# :: Integer -> Int# -- | This function calculates the integer base 2 logarithm of a -- Word#. wordLog2# :: Word# -> Int#