The
LN function returns the natural logarithm of a number. The LN and
EXP functions are inverse operations.

>>-LN--(--expression--)----------------------------------------><
The schema is SYSIBM. (The SYSFUN version of the LN
function continues to be available.)
- expression
- An expression that returns a value of any built-in numeric data
type. If the value is of decimal floating-point data type, the operation
is performed in decimal floating-point; otherwise, the value is converted
to double-precision floating-point for processing by the function.
The value of the argument must be greater than zero (SQLSTATE 22003).
If the argument is DECFLOAT(n), the result is DECFLOAT(n); otherwise, the result
is a double-precision floating-point number. The result can be null;
if the argument is null, the result is the null value.
Notes
- Results involving DECFLOAT special values: For
decimal floating-point values, the special values are treated as follows:
- LN(NaN) returns NaN.
- LN(-NaN) returns -NaN.
- LN(Infinity) returns Infinity.
- LN(-Infinity) returns NaN and a warning.
- LN(sNaN) returns NaN and a warning.
- LN(-sNaN) returns -NaN and a warning.
- LN(DECFLOAT('0') returns -Infinity.
- Syntax alternatives: LOG can be specified in place
of LN. It is supported only for compatibility with previous versions
of DB2® products. LN should be
used instead of LOG, because some database managers and applications
implement LOG as the common logarithm of a number instead of the natural
logarithm of a number.
Example
Assume that NATLOG is a DECIMAL(4,2) host variable
with a value of 31.62.
VALUES LN(:NATLOG)
Returns the approximate value 3.45.