Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Natural
- naturalLogBase :: Natural -> Natural -> Int
- naturalLog2 :: Natural -> Int
- naturalLog10 :: Natural -> Int
Documentation
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
Instances
naturalLogBase :: Natural -> Natural -> Int #
Cacluate the integer logarithm for an arbitrary base.
The base must be greater than 1, the second argument, the number
whose logarithm is sought, must be positive, otherwise an error is thrown.
If base == 2
, the specialised version is called, which is more
efficient than the general algorithm.
Satisfies:
base ^ integerLogBase base m <= m < base ^ (integerLogBase base m + 1)
for base > 1
and m > 0
.
naturalLog2 :: Natural -> Int #
Calculate the natural logarithm of an Natural
to base 2.
The argument must be non-zero, otherwise an error is thrown.
naturalLog10 :: Natural -> Int #
Calculate the integer logarithm of an Integer
to base 10.
The argument must be not zero, otherwise an error is thrown.