Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Natural
- naturalCheck# :: Natural -> Bool#
- naturalCheck :: Natural -> Bool
- naturalZero :: Natural
- naturalOne :: Natural
- naturalIsZero :: Natural -> Bool
- naturalIsOne :: Natural -> Bool
- naturalIsPowerOf2# :: Natural -> (# (# #) | Word# #)
- naturalFromBigNat# :: BigNat# -> Natural
- naturalToBigNat# :: Natural -> BigNat#
- naturalFromWord# :: Word# -> Natural
- naturalFromWord2# :: Word# -> Word# -> Natural
- naturalFromWord :: Word -> Natural
- naturalFromWordList :: [Word] -> Natural
- naturalToWord# :: Natural -> Word#
- naturalToWord :: Natural -> Word
- naturalToWordClamp# :: Natural -> Word#
- naturalToWordClamp :: Natural -> Word
- naturalToWordMaybe# :: Natural -> (# (# #) | Word# #)
- naturalEncodeDouble# :: Natural -> Int# -> Double#
- naturalEncodeFloat# :: Natural -> Int# -> Float#
- naturalEq# :: Natural -> Natural -> Bool#
- naturalEq :: Natural -> Natural -> Bool
- naturalNe# :: Natural -> Natural -> Bool#
- naturalNe :: Natural -> Natural -> Bool
- naturalGe# :: Natural -> Natural -> Bool#
- naturalGe :: Natural -> Natural -> Bool
- naturalLe# :: Natural -> Natural -> Bool#
- naturalLe :: Natural -> Natural -> Bool
- naturalGt# :: Natural -> Natural -> Bool#
- naturalGt :: Natural -> Natural -> Bool
- naturalLt# :: Natural -> Natural -> Bool#
- naturalLt :: Natural -> Natural -> Bool
- naturalCompare :: Natural -> Natural -> Ordering
- naturalPopCount# :: Natural -> Word#
- naturalPopCount :: Natural -> Word
- naturalShiftR# :: Natural -> Word# -> Natural
- naturalShiftR :: Natural -> Word -> Natural
- naturalShiftL# :: Natural -> Word# -> Natural
- naturalShiftL :: Natural -> Word -> Natural
- naturalAdd :: Natural -> Natural -> Natural
- naturalSub :: Natural -> Natural -> (# (# #) | Natural #)
- naturalSubThrow :: Natural -> Natural -> Natural
- naturalSubUnsafe :: Natural -> Natural -> Natural
- naturalMul :: Natural -> Natural -> Natural
- naturalSqr :: Natural -> Natural
- naturalSignum :: Natural -> Natural
- naturalNegate :: Natural -> Natural
- naturalQuotRem# :: Natural -> Natural -> (# Natural, Natural #)
- naturalQuotRem :: Natural -> Natural -> (Natural, Natural)
- naturalQuot :: Natural -> Natural -> Natural
- naturalRem :: Natural -> Natural -> Natural
- naturalAnd :: Natural -> Natural -> Natural
- naturalAndNot :: Natural -> Natural -> Natural
- naturalOr :: Natural -> Natural -> Natural
- naturalXor :: Natural -> Natural -> Natural
- naturalTestBit# :: Natural -> Word# -> Bool#
- naturalTestBit :: Natural -> Word -> Bool
- naturalBit# :: Word# -> Natural
- naturalBit :: Word -> Natural
- naturalGcd :: Natural -> Natural -> Natural
- naturalLcm :: Natural -> Natural -> Natural
- naturalLog2# :: Natural -> Word#
- naturalLog2 :: Natural -> Word
- naturalLogBaseWord# :: Word# -> Natural -> Word#
- naturalLogBaseWord :: Word -> Natural -> Word
- naturalLogBase# :: Natural -> Natural -> Word#
- naturalLogBase :: Natural -> Natural -> Word
- naturalPowMod :: Natural -> Natural -> Natural -> Natural
- naturalSizeInBase# :: Word# -> Natural -> Word#
- naturalToAddr# :: Natural -> Addr# -> Bool# -> State# s -> (# State# s, Word# #)
- naturalToAddr :: Natural -> Addr# -> Bool# -> IO Word
- naturalFromAddr# :: Word# -> Addr# -> Bool# -> State# s -> (# State# s, Natural #)
- naturalFromAddr :: Word# -> Addr# -> Bool# -> IO Natural
- naturalToMutableByteArray# :: Natural -> MutableByteArray# s -> Word# -> Bool# -> State# s -> (# State# s, Word# #)
- naturalFromByteArray# :: Word# -> ByteArray# -> Word# -> Bool# -> State# s -> (# State# s, Natural #)
Documentation
Natural number
Invariant: numbers <= 0xffffffffffffffff use the NS
constructor
Instances
Eq Natural Source # | |
Ord Natural Source # | |
naturalCheck# :: Natural -> Bool# Source #
Check Natural invariants
naturalCheck :: Natural -> Bool Source #
Check Natural invariants
naturalZero :: Natural Source #
Zero Natural
naturalOne :: Natural Source #
One Natural
naturalIsZero :: Natural -> Bool Source #
Test Zero Natural
naturalIsOne :: Natural -> Bool Source #
Test One Natural
naturalIsPowerOf2# :: Natural -> (# (# #) | Word# #) Source #
Indicate if the value is a power of two and which one
naturalFromBigNat# :: BigNat# -> Natural Source #
Create a Natural from a BigNat# (respect the invariants)
naturalToBigNat# :: Natural -> BigNat# Source #
Convert a Natural into a BigNat#
naturalFromWord# :: Word# -> Natural Source #
Create a Natural from a Word#
naturalFromWord2# :: Word# -> Word# -> Natural Source #
Convert two Word# (most-significant first) into a Natural
naturalFromWord :: Word -> Natural Source #
Create a Natural from a Word
naturalFromWordList :: [Word] -> Natural Source #
Create a Natural from a list of Word
naturalToWord# :: Natural -> Word# Source #
Convert the lower bits of a Natural into a Word#
naturalToWord :: Natural -> Word Source #
Convert the lower bits of a Natural into a Word
naturalToWordClamp# :: Natural -> Word# Source #
Convert a Natural into a Word# clamping to (maxBound :: Word#).
naturalToWordClamp :: Natural -> Word Source #
Convert a Natural into a Word# clamping to (maxBound :: Word).
naturalToWordMaybe# :: Natural -> (# (# #) | Word# #) Source #
naturalEncodeDouble# :: Natural -> Int# -> Double# Source #
Encode (# Natural mantissa, Int# exponent #) into a Double#
naturalEncodeFloat# :: Natural -> Int# -> Float# Source #
Encode (# Natural mantissa, Int# exponent #) into a Float#
TODO: Not sure if it's worth to write Float
optimized versions here
naturalPopCount# :: Natural -> Word# Source #
PopCount for Natural
naturalPopCount :: Natural -> Word Source #
PopCount for Natural
naturalSubThrow :: Natural -> Natural -> Natural Source #
Sub two naturals
Throw an Underflow exception if x < y
naturalSubUnsafe :: Natural -> Natural -> Natural Source #
Sub two naturals
Unsafe: don't check that x >= y Undefined results if it happens
naturalSqr :: Natural -> Natural Source #
Square a Natural
naturalSignum :: Natural -> Natural Source #
Signum for Natural
naturalNegate :: Natural -> Natural Source #
Negate for Natural
naturalQuotRem# :: Natural -> Natural -> (# Natural, Natural #) Source #
Return division quotient and remainder
Division by zero is handled by BigNat
naturalQuotRem :: Natural -> Natural -> (Natural, Natural) Source #
Return division quotient and remainder
naturalBit# :: Word# -> Natural Source #
naturalBit :: Word -> Natural Source #
naturalLog2# :: Natural -> Word# Source #
Base 2 logarithm
naturalLog2 :: Natural -> Word Source #
Base 2 logarithm
naturalPowMod :: Natural -> Natural -> Natural -> Natural Source #
"
" computes base naturalPowMod
b e mb
raised to
exponent e
modulo m
.
naturalSizeInBase# :: Word# -> Natural -> Word# Source #
Compute the number of digits of the Natural in the given base.
base
must be > 1
naturalToAddr# :: Natural -> Addr# -> Bool# -> State# s -> (# State# s, Word# #) Source #
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#
.
naturalToAddr :: Natural -> Addr# -> Bool# -> IO Word Source #
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#
.
naturalFromAddr# :: Word# -> Addr# -> Bool# -> State# s -> (# State# s, Natural #) Source #
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.
naturalFromAddr :: Word# -> Addr# -> Bool# -> IO Natural Source #
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.
naturalToMutableByteArray# :: Natural -> MutableByteArray# s -> Word# -> Bool# -> State# s -> (# State# s, Word# #) Source #
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#
.
naturalFromByteArray# :: Word# -> ByteArray# -> Word# -> Bool# -> State# s -> (# State# s, Natural #) Source #
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.