Safe Haskell | None |
---|---|
Language | Haskell2010 |
Fast Integer
logarithms to base 2. integerLog2#
and
wordLog2#
are of general usefulness, the others are only needed
for a fast implementation of fromRational
. Since they are needed
in GHC.Float, we must expose this module, but it should not show
up in the docs.
See https://gitlab.haskell.org/ghc/ghc/issues/5122 for the origin of the code in this module
Synopsis
- wordLog2# :: Word# -> Int#
- integerLog2IsPowerOf2# :: Integer -> (# Int#, Int# #)
- integerLog2# :: Integer -> Int#
- roundingMode# :: Integer -> Int# -> Int#
Documentation
wordLog2# :: Word# -> Int# Source #
Compute base-2 log of Word#
This is internally implemented as count-leading-zeros machine instruction.
integerLog2IsPowerOf2# :: Integer -> (# Int#, Int# #) Source #
Extended version of integerLog2#
Assumption: Integer is strictly positive
First component of result is log2 n
, second is 0#
iff n is a
power of two.