integer-gmp-0.4.0.0: Integer library based on GMP

Safe Haskell | None

GHC.Integer.Logarithms

Synopsis

- integerLogBase# :: Integer -> Integer -> Int#
- integerLog2# :: Integer -> Int#
- wordLog2# :: Word# -> Int#

# Documentation

integerLogBase# :: Integer -> Integer -> Int#

Calculate the integer logarithm for an arbitrary base. The base must be greater than 1, the second argument, the number whose logarithm is sought, should be positive, otherwise the result is meaningless.

     base ^ integerLogBase# base m <= m < base ^ (integerLogBase# base m + 1)

for `base > 1` and `m > 0`.

integerLog2# :: Integer -> Int#

Calculate the integer base 2 logarithm of an `Integer`. The calculation is more efficient than for the general case, on platforms with 32- or 64-bit words much more efficient.

The argument must be strictly positive, that condition is not checked.

wordLog2# :: Word# -> Int#

This function calculates the integer base 2 logarithm of a `Word#`.