LOG2(X) returns the base-2 logarithm of X : LOG2 : Math Numeric Functions MySQL TUTORIALS


MySQL TUTORIALS » Math Numeric Functions » LOG2 »

 

LOG2(X) returns the base-2 logarithm of X


If called with two parameters, this function returns the logarithm of X for an arbitrary base B.

mysql>
mysql> SELECT LOG(2,65536);
+--------------+
| LOG(2,65536|
+--------------+
|           16 |
+--------------+
row in set (0.00 sec)

mysql> SELECT LOG(10,100);
+-------------+
| LOG(10,100|
+-------------+
|           |
+-------------+
row in set (0.01 sec)

mysql>
LOG(B,Xis equivalent to LOG(X/ LOG(B).
mysql>
mysql>
mysql> SELECT LOG2(65536);
+-------------+
| LOG2(65536|
+-------------+
|          16 |
+-------------+
row in set (0.00 sec)

mysql>
mysql> SELECT LOG2(-100);
+------------+
| LOG2(-100|
+------------+
|       NULL |
+------------+
row in set (0.00 sec)

mysql>



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

MySQL TUTORIALS

 Navioo Math Numeric Functions
» LOG2