Copyright | (C) 2014 Herbert Valerio Riedel (C) 2011 Edward Kmett |
---|---|
License | see libraries/base/LICENSE |
Maintainer | libraries@haskell.org |
Stability | internal |
Portability | non-portable (GHC Extensions) |
Safe Haskell | Unsafe |
Language | Haskell2010 |
The arbitrary-precision Natural
number type.
Note: This is an internal GHC module with an API subject to
change. It's recommended use the Numeric.Natural module to import
the Natural
type.
Since: base-4.8.0.0
Synopsis
- data Natural
- isValidNatural :: Natural -> Bool
- naturalFromInteger :: Integer -> Natural
- wordToNatural :: Word -> Natural
- naturalToWordMaybe :: Natural -> Maybe Word
- minusNaturalMaybe :: Natural -> Natural -> Maybe Natural
- powModNatural :: Natural -> Natural -> Natural -> Natural
The Natural
number type
Warning: The internal implementation of Natural
(i.e. which constructors are available) depends on the
Integer
backend used!
Type representing arbitrary-precision non-negative integers.
>>>
2^20 :: Natural
1267650600228229401496703205376
Operations whose result would be negative
,throw
(Underflow
:: ArithException
)
>>>
-1 :: Natural
*** Exception: arithmetic underflow
Since: base-4.8.0.0
NatS# GmpLimb# | in |
NatJ# !BigNat | in Invariant: |
Instances
isValidNatural :: Natural -> Bool Source #
Conversions
naturalFromInteger :: Integer -> Natural Source #
Since: base-4.10.0.0
Checked subtraction
Modular arithmetic
powModNatural :: Natural -> Natural -> Natural -> Natural Source #
"
" computes base powModNatural
b e mb
raised to
exponent e
modulo m
.
Since: base-4.8.0.0