LOG

The LOG function calculates the base 2 logarithm of a number.

Syntax

LOG( INT value )

Return value

An INT value containing the base 2 logarithm of value rounded down to nearest integer value.

Errors

If zero is passed to LOG, then an error occurs.

Example

INT i;

FOR i := 1 TO 8
  PRINT("LOG(", i, "): ", LOG(i), "\n");
END;

The output will be:

LOG(1) = 0
LOG(2) = 1
LOG(3) = 1
LOG(4) = 2
LOG(5) = 2
LOG(6) = 2
LOG(7) = 2
LOG(8) = 3