Caché Basic Reference
Log


Returns the natural logarithm of a number.
Synopsis
Arguments
The number argument can be any valid numeric expression greater than 0. Specifying 0 or a negative number results in a runtime error.
Description
The natural logarithm is the logarithm to the base e. The constant e (
Exp(1)) is approximately 2.718282.
You can calculate base
n logarithms for any number
x by dividing the natural logarithm of
x by the natural logarithm of
n as follows:
Logn(x) = Log(x) / Log(n)
Note:
In ObjectScript, the equivalent function is the
$ZLN function, which returns the natural logarithm. The
$ZLOG function returns the base10 logarithm. Please note that
Log and
$ZLOG are
not equivalent functions.
Examples
The following example uses the
Log function to calculate the natural logarithm for each of the integers 1 through 10:
For x = 1 To 10
Println "Natural log of ",x," = ",Log(x)
Next
The following example uses the
Log function to calculate the base10 logarithms for the numbers 10 through 100, counting by tens. For 100, it returns 2 (10 to the power of
x = 100).
x = 10
For y = 1 To 10
Base10 = Log(x) / Log(10)
Println "Base10 log of ",x," = ",Base10
x = x + 10
Next
See Also