LN

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

Read syntax diagramSkip visual syntax diagram
>>-LN--(--expression--)----------------------------------------><

expression
An expression that returns a value of any built-in numeric, character-string, or graphic-string data type. A string argument is cast to double-precision floating point before evaluating the function. For more information about converting strings to double-precision floating point, see DOUBLE_PRECISION or DOUBLE. The value of the argument must be greater than zero.

If the data type of the argument is DECFLOAT(n), the result is DECFLOAT(n). Otherwise, the data type of the result is double-precision floating point. If the argument can be null, the result can be null; if the argument is null, the result is the null value.

Note

Start of changeResults involving DECFLOAT special values: For decimal floating-point values the special values are treated as follows:
  • LN(NaN) returns NaN. 1
  • LN(-NaN) returns NaN. 1
  • LN(Infinity) returns Infinity.
  • LN(-Infinity) returns NaN. 1.
  • LN(sNaN) and LN(-sNaN) return a warning or error.
  • LN(0) returns -Infinity.
  • LN with a negative argument, including -Infinity, returns NaN. 1
End of change

Example

1 If *YES is specified for the SQL_DECFLOAT_WARNINGS query option a warning is returned.