Skip to content

LOG2()

Function Description

The LOG2(X) function returns the logarithm of X with base 2.

Function Syntax

> LOG2(X)

Parameter definition

Parameters Description
X Required parameters, any currently supported numerical data

Example

drop table if exists t1;
create table t1(a float, b float);
insert into t1 values(1024,17.231);
insert into t1 values(4096,23.331);

mysql>select log2(a),log2(b) from t1;
+---------------------------------------+
| log2(a) | log2(b) |
+---------------------------------------+
| 10 | 4.106934600972237 |
| 12 | 4.544176200820541 |
+---------------------------------------+
2 rows in set (0.01 sec)