Function Reference

LOG

Returns the base-10 logarithm of a number or its logarithm to the given base.

PostgreSQL 17.9
LOG([base, ]num)
  • [ ]optional part
base
Logarithm base, 10 by default
numericOptional
num
Number to take the logarithm of
numeric | double precision

Return value

A number of the same type as num, numeric with base; an error if num ≤ 0, base ≤ 0 or base = 1

Examples

Logarithm to base 2

PostgreSQL 17.9
SELECT LOG(2, 8);
log
3.0000000000000000

Base-10 logarithm

PostgreSQL 17.9
SELECT LOG(100);
log
2

Details

The natural logarithm is computed by LN. In MySQL LOG(num) with one argument is the natural logarithm, while here it is the base-10 logarithm, like LOG10.

See also

Where to learn