SELECT LOG2(7); // Output is 2.8073549220576
SELECT LOG2(0.1); // Output is -3.32192809488736
SELECT LOG2(0); // Output is NULL
SELECT ROUND(LOG2(8),2);// Output is 3.00
SELECT ROUND(LOG2(-5),2); // Output is NULL
SELECT ROUND(LOG2(9),2); // Output is 3.17
Syntax
SELECT LOG2( X )
Returns natural logarithm of X with base 2. When X is less than or equal to 0.0E0 we get NULL as output.
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.