Outdated Version
You are viewing an older version of this section. View current production version.
LOG
Returns the logarithm of the given argument in the given base. If only one argument is given, this function returns the “natural” logarithm to base e.
Syntax
LOG ( base, number )
LOG ( number )
Arguments
- base: the base of the logarithm.
- number: the number to take the logarithm of.
Info
log(n) is an alias for ln(n).
log(b, n) is equivalent to ln(n) / ln(b).
Return Type
Float or double. If number is less than or equal to 0, or if base is non-positive or 1, returns NULL.
Examples
select log(2, 16);
+------------+
| log(2, 16) |
+------------+
| 4 |
+------------+
select log(2, 1234);
+-------------------+
| log(2, 1234) |
+-------------------+
| 10.26912667914942 |
+-------------------+
select log(1234);
+--------------------+
| log(1234) |
+--------------------+
| 7.1180162044653335 |
+--------------------+
select ln(1234);
+--------------------+
| ln(1234) |
+--------------------+
| 7.1180162044653335 |
+--------------------+
select log(10, 1000), ln(1000) / ln(10);
+--------------------+--------------------+
| log(10, 1000) | ln(1000) / ln(10) |
+--------------------+--------------------+
| 2.9999999999999996 | 2.9999999999999996 |
+--------------------+--------------------+
select log(-9);
+---------+
| log(-9) |
+---------+
| NULL |
+---------+