LOG10

The LOG10 function returns the common logarithm (base 10) of a number. The LOG10 and ANTILOG functions are inverse operations.

LOG10(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.

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

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

Syntax alternatives: LOG is a synonym for LOG10. It is supported only for compatibility with previous DB2® releases. LOG10 should be used instead of LOG because some database managers and applications implement LOG as the natural logarithm of a number instead of the common logarithm of a number.

Example

  • Assume the host variable L is a DECIMAL(4,2) host variable with a value of 31.62.
      SELECT LOG10(:L)
        FROM SYSIBM.SYSDUMMY1
    Returns the approximate value 1.49.
1 If *YES is specified for the SQL_DECFLOAT_WARNINGS query option, NaN is returned with a warning.