HORIZON HASKELLDocslts/ghc-10.0.x8174fa42026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8174fa4 · 2026-10-11

Moduleghc-internal-10.0.0Haskell2010

GHC.Internal.Bignum.BigNat

Multi-precision natural

  • 2 types
  • 136 values
typetype BigNat# = WordArray#
#

A 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.

datadata BigNat
#

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.

Constructors

Instances2Eq, Ord
  • Eq BigNatDefined in ghc-internal-10.0.0 · GHC.Internal.Bignum.BigNat
  • Ord BigNatDefined in ghc-internal-10.0.0 · GHC.Internal.Bignum.BigNat
valuegcdInt# :: Int# -> Int# -> Int#
#

Greatest common divisor between two Int#

Warning: result may become negative if (at least) one argument is minBound

valuegcdInt :: Int -> Int -> Int
#

Greatest common divisor between two Int

Warning: result may become negative if (at least) one argument is minBound

valuebigNatBit# :: Word# -> BigNat#
#

Return a BigNat whose bit i is the only one set.

Specialized version of `bigNatShiftL (bigNatFromWord# 1##)`

valuebigNatBit :: Word -> BigNat#
#

Return a BigNat whose bit i is the only one set.

Specialized version of `bigNatShiftL (bigNatFromWord# 1##)`

valuebigNatToAddrLE# :: BigNat# -> Addr# -> State# s -> (# State# s, Word# #)
#

Write a BigNat in base-256 little-endian representation and return the number of bytes written.

Use "bigNatSizeInBase 256# i" to compute the exact number of bytes written in advance. In case of i == 0, the function will write and report zero bytes written.

valuebigNatToAddrBE# :: BigNat# -> Addr# -> State# s -> (# State# s, Word# #)
#

Write a BigNat in base-256 big-endian representation and return the number of bytes written.

Use "bigNatSizeInBase 256# i" to compute the exact number of bytes written in advance. In case of i == 0, the function will write and report zero bytes written.

valuebigNatToAddr#
  1. :: BigNat#
  2. -> Addr#
  3. -> Bool#
  4. -> State# s
  5. -> (# State# s, Word# #)
#

Write a BigNat in base-256 representation and return the number of bytes written.

The endianness is selected with the Bool# parameter: most significant byte first (big-endian) if 1# or least significant byte first (little-endian) if 0#.

Use "bigNatSizeInBase 256# i" to compute the exact number of bytes written in advance. In case of i == 0, the function will write and report zero bytes written.

valuebigNatToAddr :: BigNat# -> Addr# -> Bool# -> IO Word
#

Write a BigNat in base-256 representation and return the number of bytes written.

The endianness is selected with the Bool# parameter: most significant byte first (big-endian) if 1# or least significant byte first (little-endian) if 0#.

Use "bigNatSizeInBase 256# i" to compute the exact number of bytes written in advance. In case of i == 0, the function will write and report zero bytes written.

valuebigNatFromAddr#
  1. :: Word#
  2. -> Addr#
  3. -> Bool#
  4. -> State# s
  5. -> (# State# s, BigNat# #)
#

Read a BigNat in base-256 representation from an Addr#.

The size is given in bytes.

The endianness is selected with the Bool# parameter: most significant byte first (big-endian) if 1# or least significant byte first (little-endian) if 0#.

Null higher limbs are automatically trimmed.

Write a BigNat in base-256 representation and return the number of bytes written.

The endianness is selected with the Bool# parameter: most significant byte first (big-endian) if 1# or least significant byte first (little-endian) if 0#.

Use "bigNatSizeInBase 256# i" to compute the exact number of bytes written in advance. In case of i == 0, the function will write and report zero bytes written.

Read a BigNat in base-256 representation from a ByteArray#.

The size is given in bytes.

The endianness is selected with the Bool# parameter: most significant byte first (big-endian) if 1# or least significant byte first (little-endian) if 0#.

Null higher limbs are automatically trimmed.