
msb(+Number, -Result)
-Result is msb(+Number)

   Result is the index of the most significant nonzero bit

Arguments
   Number              Positive Integer
   Result              Output: integer.

Type
   Arithmetic

Description

   Returns the index of the most significant nonzero bit in Number's
   binary representation.  The least significant bit has index zero.
   Only defined for Number greater than zero.

   This predicate can be used as a function in arithmetic expressions.
   In coroutining mode, if Number is uninstantiated, the call
   is delayed until it is instantiated.



Modes and Determinism
   msb(+, -) is det

Exceptions
     4 --- Number or Index is not instantiated (non-coroutining mode    only).
     5 --- Number or Index is a number but not an integer
     6 --- Number is less than 1
    24 --- Number or Index is not of a numeric type

Examples
   
    Result is msb(1).           % gives Result = 0.
    Result is msb(4).           % gives Result = 2.
    Result is msb(40).          % gives Result = 5. (40 is binary 101000)


See Also
   is / 2, getbit / 3, clrbit / 3, setbit / 3, lsb / 2, popcount / 2
