PostgreSQL log10() Function
The PostgreSQL log10()
function returns the base 10 logarithm of the number specified by the argument.
log10()
Syntax
This is the syntax of the PostgreSQL log10()
function:
log10(numeric_value) -> double precision
Parameters
numeric_value
-
Required. A number whose logarithm needs to be obtained.
Return value
The PostgreSQL log10()
function returns the base 10 logarithm of the number specified by the argument.
The log10()
function will return NULL
if the argument is NULL
.
If the argument is zero, PostgreSQL will give an error: “Cannot take logarithm of zero”.
If the argument is negative, PostgreSQL will give an error: “Cannot take logarithm of negative number”.
PostgreSQL will give an error if you supply a parameter that is not a numeric type.
log10()
Examples
Here are a few examples of the log10()
function:
SELECT
log10(1) AS "log10(1)",
log10(2) AS "log10(-2)",
log10(3.3) AS "log10(3.3)";
log10(1) | log10(-2) | log10(3.3)
----------+--------------------+--------------------
0 | 0.3010299956639812 | 0.5185139398778875