Calculates the logarithm of an expression using a specified base and returns that logarithm as a DECIMAL value.
LOG ( expression , 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.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.
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.
![]()
After converting the base and exponent to floating-point format, the LOG function uses standard system routines. On some machines, the logarithm routines do not handle large numbers well and might cause your terminal to hang.
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates. |