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

   Result is the index of the least significant nonzero bit

Arguments
   Number              Positive Integer
   Result              Output: integer.

Type
   Arithmetic

Description

   Returns the index of the least 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
   lsb(+, -) 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 lsb(1).           % gives Result = 0.
    Result is lsb(4).           % gives Result = 2.
    Result is lsb(40).          % gives Result = 3. (40 is binary 101000)


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