Copyright | (c) Herbert Valerio Riedel 2014 |
---|---|
License | BSD3 |
Maintainer | ghc-devs@haskell.org |
Stability | provisional |
Portability | non-portable (GHC Extensions) |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- data Integer where
- isValidInteger# :: Integer -> Int#
- module GHC.Integer
- gcdInteger :: Integer -> Integer -> Integer
- gcdExtInteger :: Integer -> Integer -> (# Integer, Integer #)
- lcmInteger :: Integer -> Integer -> Integer
- sqrInteger :: Integer -> Integer
- powModInteger :: Integer -> Integer -> Integer -> Integer
- recipModInteger :: Integer -> Integer -> Integer
- wordToNegInteger :: Word# -> Integer
- bigNatToInteger :: BigNat -> Integer
- bigNatToNegInteger :: BigNat -> Integer
- data BigNat = BN# {}
- type GmpLimb = Word
- type GmpLimb# = Word#
- type GmpSize = Int
- type GmpSize# = Int#
- isValidBigNat# :: BigNat -> Int#
- sizeofBigNat# :: BigNat -> GmpSize#
- zeroBigNat :: BigNat
- oneBigNat :: BigNat
- byteArrayToBigNat# :: ByteArray# -> GmpSize# -> BigNat
- wordToBigNat :: Word# -> BigNat
- wordToBigNat2 :: Word# -> Word# -> BigNat
- bigNatToInt :: BigNat -> Int#
- bigNatToWord :: BigNat -> Word#
- indexBigNat# :: BigNat -> GmpSize# -> GmpLimb#
- plusBigNat :: BigNat -> BigNat -> BigNat
- plusBigNatWord :: BigNat -> GmpLimb# -> BigNat
- minusBigNat :: BigNat -> BigNat -> BigNat
- minusBigNatWord :: BigNat -> GmpLimb# -> BigNat
- timesBigNat :: BigNat -> BigNat -> BigNat
- timesBigNatWord :: BigNat -> GmpLimb# -> BigNat
- sqrBigNat :: BigNat -> BigNat
- quotRemBigNat :: BigNat -> BigNat -> (# BigNat, BigNat #)
- quotRemBigNatWord :: BigNat -> GmpLimb# -> (# BigNat, GmpLimb# #)
- quotBigNatWord :: BigNat -> GmpLimb# -> BigNat
- quotBigNat :: BigNat -> BigNat -> BigNat
- remBigNat :: BigNat -> BigNat -> BigNat
- remBigNatWord :: BigNat -> GmpLimb# -> Word#
- gcdBigNat :: BigNat -> BigNat -> BigNat
- gcdBigNatWord :: BigNat -> Word# -> Word#
- 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
- bitBigNat :: Int# -> BigNat
- isZeroBigNat :: BigNat -> Bool
- 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#
- sizeInBaseBigNat :: BigNat -> Int# -> Word#
- sizeInBaseInteger :: Integer -> Int# -> Word#
- sizeInBaseWord# :: Word# -> Int# -> Word#
- exportBigNatToAddr :: BigNat -> Addr# -> Int# -> IO Word
- exportIntegerToAddr :: Integer -> Addr# -> Int# -> IO Word
- exportBigNatToMutableByteArray :: BigNat -> MutableByteArray# RealWorld -> Word# -> Int# -> IO Word
- exportIntegerToMutableByteArray :: Integer -> MutableByteArray# RealWorld -> Word# -> Int# -> IO Word
- importBigNatFromAddr :: Addr# -> Word# -> Int# -> IO BigNat
- importIntegerFromAddr :: Addr# -> Word# -> Int# -> IO Integer
- importBigNatFromByteArray :: ByteArray# -> Word# -> Word# -> Int# -> BigNat
- importIntegerFromByteArray :: ByteArray# -> Word# -> Word# -> Int# -> Integer
The Integer
type
Arbitrary precision integers. In contrast with fixed-size integral types
such as Int
, the Integer
type represents the entire infinite range of
integers.
Integers are stored in a kind of sign-magnitude form, hence do not expect two's complement form when using bit operations.
If the value is small (fit into an Int
), IS
constructor is used.
Otherwise IP
and IN
constructors are used to store a BigNat
representing respectively the positive or the negative value magnitude.
pattern S# :: Int# -> Integer | Deprecated: Use IS constructor instead |
pattern Jn# :: BigNat -> Integer | Deprecated: Use IN constructor instead |
pattern Jp# :: BigNat -> Integer | Deprecated: Use IP constructor instead |
Instances
Show Integer | Since: base-2.1 |
Eq Integer | |
Ord Integer | |
isValidInteger# :: Integer -> Int# Source #
Deprecated: Use integerCheck# instead
Basic Integer
operations
module GHC.Integer
Additional Integer
operations
gcdExtInteger :: Integer -> Integer -> (# Integer, Integer #) Source #
Deprecated: Use integerGcde instead
sqrInteger :: Integer -> Integer Source #
Deprecated: Use integerSqr instead
powModInteger :: Integer -> Integer -> Integer -> Integer Source #
Deprecated: Use integerPowMod# instead
Additional conversion operations to Integer
wordToNegInteger :: Word# -> Integer Source #
Deprecated: Use integerFromWordNeg# instead
bigNatToInteger :: BigNat -> Integer Source #
Deprecated: Use integerFromBigNat# instead
bigNatToNegInteger :: BigNat -> Integer Source #
Deprecated: Use integerFromBigNatNeg# instead
The BigNat
type
A lifted BigNat
Represented as an array of limbs (Word#) stored in little-endian order (Word# themselves use machine order).
Invariant (canonical representation): higher Word# is non-zero.
As a consequence, zero is represented with a WordArray# whose size is 0.
Instances
Eq BigNat | |
Ord BigNat | |
Defined in GHC.Num.BigNat |
isValidBigNat# :: BigNat -> Int# Source #
Deprecated: Use bigNatCheck# instead
sizeofBigNat# :: BigNat -> GmpSize# Source #
Deprecated: Use bigNatSize# instead
zeroBigNat :: BigNat Source #
Deprecated: Use bigNatZero instead
Conversions to/from BigNat
byteArrayToBigNat# :: ByteArray# -> GmpSize# -> BigNat Source #
Deprecated: Use bigNatFromWordArray instead
wordToBigNat :: Word# -> BigNat Source #
bigNatToInt :: BigNat -> Int# Source #
bigNatToWord :: BigNat -> Word# Source #
BigNat
arithmetic operations
quotRemBigNat :: BigNat -> BigNat -> (# BigNat, BigNat #) Source #
Deprecated: Use bigNatQuotRem# instead
quotRemBigNatWord :: BigNat -> GmpLimb# -> (# BigNat, GmpLimb# #) Source #
Deprecated: Use bigNatQuotRemWord# instead
BigNat
logic operations
complementBitBigNat :: BigNat -> Int# -> BigNat Source #
Deprecated: Use bigNatComplementBit# instead
popCountBigNat :: BigNat -> Int# Source #
Deprecated: Use bigNatPopCount# instead
BigNat
comparison predicates
isZeroBigNat :: BigNat -> Bool Source #
Deprecated: Use bigNatIsZero instead
compareBigNatWord :: BigNat -> GmpLimb# -> Ordering Source #
Deprecated: Use bigNatCompareWord# instead
Import/export functions
Compute size of serialisation
Export
exportBigNatToAddr :: BigNat -> Addr# -> Int# -> IO Word Source #
Deprecated: Use bigNatToAddr# instead
exportIntegerToAddr :: Integer -> Addr# -> Int# -> IO Word Source #
Deprecated: Use integerToAddr# instead
exportBigNatToMutableByteArray :: BigNat -> MutableByteArray# RealWorld -> Word# -> Int# -> IO Word Source #
Deprecated: Use bigNatToMutableByteArray# instead
exportIntegerToMutableByteArray :: Integer -> MutableByteArray# RealWorld -> Word# -> Int# -> IO Word Source #
Deprecated: Use integerToMutableByteArray# instead
Import
importBigNatFromAddr :: Addr# -> Word# -> Int# -> IO BigNat Source #
Deprecated: Use bigNatFromAddr# instead
importIntegerFromAddr :: Addr# -> Word# -> Int# -> IO Integer Source #
Deprecated: Use integerFromAddr# instead
importBigNatFromByteArray :: ByteArray# -> Word# -> Word# -> Int# -> BigNat Source #
Deprecated: Use bigNatFromByteArray# instead
importIntegerFromByteArray :: ByteArray# -> Word# -> Word# -> Int# -> Integer Source #
Deprecated: Use integerFromByteArray# instead