Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRIS, see the InterSystems IRIS Adoption Guide and the InterSystems IRIS In-Place Conversion Guide, both available on the WRC Distributions page (login required).

Previous sectionNext section


Returns the natural logarithm of a number.




The number argument can be any valid numeric expression greater than 0. Specifying 0 or a negative number results in a runtime error.


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)
Copy code to clipboard

In ObjectScript, the equivalent function is the $ZLN function, which returns the natural logarithm. The $ZLOG function returns the base-10 logarithm. Please note that Log and $ZLOG are not equivalent functions.


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)
Copy code to clipboard

The following example uses the Log function to calculate the base-10 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 "Base-10 log of ",x," = ",Base10
x = x + 10
Copy code to clipboard

See Also