Add two bigNats
Modulebase-4.22.0.0Haskell2010
GHC.Num.BigNat
- 2 types
- 136 values
- Packagebase-4.22.0.0
- Exports138
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceBigNat.hs
Add a bigNat and a Word
Add a bigNat and a Word#
Bitwise AND
Bitwise AND with Int#
Bitwise ANDNOT
Bitwise ANDNOT with Word#
Bitwise AND with Word#
Return a BigNat whose bit i is the only one set.
Specialized version of `bigNatShiftL (bigNatFromWord# 1##)`
Return a BigNat whose bit i is the only one set.
Specialized version of `bigNatShiftL (bigNatFromWord# 1##)`
Check that the BigNat is valid
Check that the BigNat is valid
BigNat clear bit
Compare two BigNat
Compare a BigNat and a Word
Compare a BigNat and a Word#
Reverse the given bit
Return count of trailing zero bits
Return 0 for zero BigNat
Return count of trailing zero bits
Return 0 for zero BigNat
Return count of trailing zero words
Return 0 for zero BigNat
Return count of trailing zero words
Return 0 for zero BigNat
Encode (# BigNat mantissa, Int# exponent #) into a Double#
Equality test for BigNat
Equality test for BigNat
Test if a BigNat is equal to a Word
Return the absolute value of the Int# in a 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.
Read a BigNat in base-256 big-endian representation from an Addr#.
The size is given in bytes.
Null higher limbs are automatically trimmed.
Read a BigNat in base-256 little-endian representation from an Addr#.
The size is given in bytes.
Higher limbs equal to 0 are automatically trimmed.
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.
Read a BigNat in base-256 big-endian representation from a ByteArray#.
The size is given in bytes.
Null higher limbs are automatically trimmed.
Read a BigNat in base-256 little-endian representation from a ByteArray#.
The size is given in bytes.
Null higher limbs are automatically trimmed.
Create a BigNat from a Word
Create a BigNat from a Word
Convert two Word# (most-significant first) into a BigNat
Convert a Word64# into a BigNat on 64-bit architectures
Create a BigNat from a WordArray# containing n limbs in least-significant-first order.
If possible WordArray#, will be used directly (i.e. shared without cloning the WordArray# into a newly allocated one)
Create a BigNat# from a WordArray# containing n limbs in least-significant-first order.
If possible WordArray#, will be used directly (i.e. shared without cloning the WordArray# into a newly allocated one)
Convert a list of non-zero Words (most-significant first) into a BigNat
Convert a list of non-zero Words (most-significant first) into a BigNat
Convert a list of non-zero Words (most-significant first) into a BigNat. Don't remove most-significant zero words
Greatest common divisor
Greatest common divisor
Predicate: a >= b
Predicate: a >= b
Predicate: a > b
Predicate: a > b
Test if a BigNat is greater than a Word
Test if a BigNat is greater than a Word
Return the Word# at the given index
Return the Word# at the given index
Indicate if a bigNat is one
Indicate if a bigNat is one
Indicate if the value is a power of two and which one
Indicate if a bigNat is two
Indicate if a bigNat is two
Indicate if a bigNat is zero
Indicate if a bigNat is zero
Least common multiple
Least common multiple with a Word#
Least common multiple between two Word#
Predicate: a <= b
Predicate: a <= b
Test if a BigNat is lower than or equal to a Word
Test if a BigNat is lower than or equal to a Word
Base 2 logarithm
Base 2 logarithm
Logarithm for an arbitrary base
Logarithm for an arbitrary base
Logarithm for an arbitrary base
Logarithm for an arbitrary base
Predicate: a < b
Predicate: a < b
Multiplication (classical algorithm)
Multiply a BigNAt by a Word
Multiply a BigNat by a Word#
Equality test for BigNat
Inequality test for BigNat
BigNat one
Bitwise OR
Bitwise OR with Word#
PopCount for BigNat
PopCount for BigNat
"bigNatPowMod b e m" computes base b raised to
exponent e modulo m.
"bigNatPowModWord# b e m" computes base b raised to
exponent e modulo m.
BigNat division returning quotient
BigNat division returning (quotient,remainder)
QuotRem a BigNat by a Word
Require: b /= 0
Divide a BigNat by a Word, return the quotient
Require: b /= 0
Divide a BigNat by a Word, return the quotient
Require: b /= 0
BigNat division returning remainder
Divide a BigNat by a Word, return the remainder
Require: b /= 0
Divide a BigNat by a Word, return the remainder
Require: b /= 0
BigNat set bit
Bit shift left
Bit shift left
Bit shift right
Bit shift right
Bit shift right (two's complement)
Number of words in the BigNat
Number of words in the BigNat
Compute the number of digits of the BigNat in the given base.
base must be > 1
Compute the number of digits of the BigNat in the given base.
base must be > 1
Square a BigNat
Subtract two BigNat
Subtract two BigNat (don't check if a >= b)
Subtract a Word# from a BigNat
Subtract a Word# from a BigNat
The BigNat must be bigger than the Word#.
Subtract a Word# from a BigNat
The BigNat must be bigger than the Word#.
BigNat bit test
BigNat bit test
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.
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.
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.
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.
Convert a BigNat into a Int
Convert a BigNat into a Int#
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.
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.
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.
Convert a BigNat into a Word
Convert a BigNat into a Word#
Convert a BigNat into a Word64# on 64-bit architectures
Convert a BigNat into a list of non-zero Words (most-significant first)
Convert a BigNat into a Word# if it fits
Bitwise XOR
Bitwise XOR with Word#
BigNat Zero
Greatest common divisor between two Int
Warning: result may become negative if (at least) one argument
is minBound
Greatest common divisor between two Int#
Warning: result may become negative if (at least) one argument
is minBound
Greatest common divisor between two Word
Greatest common divisor between two Word#
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.
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.