DB2 Scalar functions - LN


Volta a página anterior

Volta ao Menu das scalar functions

Volta ao Menu Principal


Desenvolvido por DORNELLES Carlos Alberto - Analista de Sistemas - Brasília DF. - cad_cobol@hotmail.com

LN

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:
    For compatibility with other SQL dialects, LOG can be specified in place of LN.
    However, because some database managers and applications use LOG to mean a common logarithm rather than a natural logarithm, use LN instead of LOG whenever possible.

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.


© Copyright IBM Corp.