W3cubDocs

/Haskell 8

GHC.Integer.Logarithms.Internals

Safe Haskell None
Language Haskell2010

Description

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://ghc.haskell.org/trac/ghc/ticket/5122 for the origin of the code in this module

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.

integerLog2# :: Integer -> Int# Source

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.

roundingMode# :: Integer -> Int# -> Int# Source

© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).
https://downloads.haskell.org/~ghc/8.8.3/docs/html/libraries/integer-gmp-1.0.2.0/GHC-Integer-Logarithms-Internals.html