Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

MySQL LOG2() function

LOG2() function

MySQL LOG2() returns the natural logarithm of a number to the base 2.


Syntax:

LOG2(N);

Argument:

Name Description
N A number.

Note :The equivalent expression for this function is LOG(N) / LOG(2).

Syntax Diagram:

MySQL LOG2() Function - Syntax Diagram

MySQL Version: 5.6


Pictorial presentation of MySQL LOG2() function

pictorial presentation of MySQL LOG2() function

Example of MySQL LOG2() function

Code:

SELECT LOG2(256);

Explanation:

The above MySQL statement returns the natural logarithm of 256 as specified in the argument to the base 2.

Sample Output:

mysql> SELECT LOG2(256);
+-----------+
| LOG2(256) |
+-----------+
|         8 | 
+-----------+
1 row in set (0.00 sec)

All Mathematical Functions

MySQL Mathematical Functions, slide presentation

Previous: LOG()
Next: LOG10()