LOG2
Description
Returns the natural logarithm of x
to base 2
.
Syntax
LOG2(<x>)
Parameters
Parameter | Description |
---|---|
<x> | Antilogarithm should be greater than 0 |
Return value
Returns a floating-point number. Special cases:
- If x IS NULL, return
NULL
- If x IS NaN, return NaN
Example
select log2(1);
+-------------------------+
| log2(cast(1 as DOUBLE)) |
+-------------------------+
| 0.0 |
+-------------------------+
select log2(2);
+-------------------------+
| log2(cast(2 as DOUBLE)) |
+-------------------------+
| 1.0 |
+-------------------------+
select log2(10);
+--------------------------+
| log2(cast(10 as DOUBLE)) |
+--------------------------+
| 3.3219280948873626 |
+--------------------------+
select log2(NULL);
+------------+
| log2(NULL) |
+------------+
| NULL |
+------------+
select log2(cast('Nan' as double));
+-----------------------------+
| log2(cast('Nan' as double)) |
+-----------------------------+
| NaN |
+-----------------------------+