LOG function

Calculates the logarithm of an expression using a specified base and returns that logarithm as a DECIMAL value.

Syntax

LOG ( expression [ , base ] )
expression
A decimal expression that you want the logarithm of.
base
A numeric expression that is the base you want to use. If you do not specify a base, LOG returns the natural logarithm, base (e). The base must be greater than 1.

Example

This procedure prompts the user for a base and a number, and then displays the log of the number. The VALIDATE option on the UPDATE statement ensures that the user enters a base value greater than 1 and a number greater than 0.

r-log.p

DEFINE VARIABLE base   AS DECIMAL NO-UNDO FORMAT ">>>,>>>.9999".
DEFINE VARIABLE number AS DECIMAL NO-UNDO.

REPEAT:
  UPDATE base VALIDATE(base > 1, "Base must be greater than 1").
  REPEAT:
    UPDATE number VALIDATE(number > 0, "Number must be positive").
    DISPLAY number LOG(number, base) LABEL "LOG(NUMBER, BASE)".
  END.
END.

Notes