ilog2.pl -- A Collection of Numerical Snippets :: ilog2

Part of Nan.Numerics.Gist (nan/numerics/gist.pl)

This module provides predicates that implement different algorithms for the computation of the integer binary logarithm in arbitrary precision.

To the purpose of comparing efficiency, predicates in this module return the count of elementary arithmetic operations performed.

Three variants are offered which are further refinements on the naive approach that increases the bit mask by one bit at a time:

NOTE: This module is not meant to provide production-ready Prolog code.

author
- Julio P. Di Egidio
version
- 1.1.1-beta
license
- GNU GPLv3
ilog2_n(+X:posint, -Y:nonnegint, -C:nonnegint) is det
ilog2_i(+X:posint, -Y:nonnegint, -C:nonnegint) is det
ilog2_test(:G:call, -C:nonnegint) is det
ilog2_print(:G:call, +L:posint, +H:posint, +X0:nonnegint) is det