Skip to main content
Last updated on

LN

Description​

Returns the natural logarithm of x to base e.

Alias​

  • DLOG1

Syntax​

LN(<x>)

Parameters​

ParameterDescription
<x>Antilogarithm should be greater than 0

Return value​

Return a float-point number. Special cases:

  • If x IS NULL, return NULL
  • If x IS NaN, return NaN
  • If x is positive infinity, return Infinity

Example​

select ln(1);
+-----------------------+
| ln(cast(1 as DOUBLE)) |
+-----------------------+
| 0.0 |
+-----------------------+
select ln(e());
+---------+
| ln(e()) |
+---------+
| 1.0 |
+---------+
select ln(10);
+------------------------+
| ln(cast(10 as DOUBLE)) |
+------------------------+
| 2.302585092994046 |
+------------------------+
select ln(cast('inf' as double));
+---------------------------+
| ln(cast('inf' as double)) |
+---------------------------+
| Infinity |
+---------------------------+
select ln(cast('nan' as double));
+---------------------------+
| ln(cast('nan' as double)) |
+---------------------------+
| NaN |
+---------------------------+