Add two naturals
Modulebase-4.22.0.0Haskell2010
GHC.Num.Natural
- 1 type
- 81 values
- Packagebase-4.22.0.0
- Exports82
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceNatural.hs
Check Natural invariants
Check Natural invariants
Compare two Natural
Encode (# Natural mantissa, Int# exponent #) into a Double#
Encode (# Natural mantissa, Int# exponent #) into a Float#
TODO: Not sure if it's worth to write Float optimized versions here
Equality test for Natural
Equality test for Natural
Read a Natural 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 trimed.
Read a Natural 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 trimed.
Create a Natural from a BigNat# (respect the invariants)
Read a Natural 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 trimed.
Create a Natural from a Word
Create a Natural from a Word#
Convert two Word# (most-significant first) into a Natural
Create a Natural from a list of Word
Compute greatest common divisor.
Greater or equal test for Natural
Greater or equal test for Natural
Greater test for Natural
Greater test for Natural
Test One Natural
Indicate if the value is a power of two and which one
Test Zero Natural
Compute least common multiple.
Lower or equal test for Natural
Lower or equal test for Natural
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
Lower test for Natural
Lower test for Natural
Multiplication
Inequality test for Natural
Inequality test for Natural
Negate for Natural
One Natural
PopCount for Natural
PopCount for Natural
"naturalPowMod b e m" computes base b raised to
exponent e modulo m.
Return division quotient
Return division quotient and remainder
Return division quotient and remainder
Division by zero is handled by BigNat
Return division remainder
Left shift
Left shift
Right shift for Natural
Right shift for Natural
Signum for Natural
Compute the number of digits of the Natural in the given base.
base must be > 1
Square a Natural
Sub two naturals
Sub two naturals
Throw an Underflow exception if x < y
Sub two naturals
Unsafe: don't check that x >= y Undefined results if it happens
Write a Natural to addr in base-256 representation and return the
number of bytes written.
The endianness is selected with the Bool# parameter: write most significant
byte first (big-endian) if 1# or least significant byte first
(little-endian) if 0#.
Write a Natural to addr in base-256 representation and return the
number of bytes written.
The endianness is selected with the Bool# parameter: write most significant
byte first (big-endian) if 1# or least significant byte first
(little-endian) if 0#.
Convert a Natural into a BigNat#
Write a Natural 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#.
Convert the lower bits of a Natural into a Word
Convert the lower bits of a Natural into a Word#
Convert a Natural into a Word# clamping to (maxBound :: Word).
Convert a Natural into a Word# clamping to (maxBound :: Word#).
Zero Natural
Natural number
Invariant: numbers <= 0xffffffffffffffff use the NS constructor
Constructors
Instances16Enum, Eq, Integral, Data, Num, Ord, …
Enum NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.EnumEq NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.Bignum.NaturalIntegral NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.RealData NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.Data.DataNum NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.NumOrd NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.Bignum.NaturalRead NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.ReadReal NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.RealShow NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.ShowIx NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.IxBits NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.BitsPrintfArg NaturalDefined in base-4.22.0.0 · Text.PrintfLift NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.LiftTestCoercion SNatDefined in ghc-internal-9.1401.0 · GHC.Internal.TypeNatsTestEquality SNatDefined in ghc-internal-9.1401.0 · GHC.Internal.TypeNatstype Compare a b = CmpNat a bDefined in ghc-internal-9.1401.0 · GHC.Internal.Data.Type.Ord