totn MariaDB Functions

MariaDB: LOG2 Function

This MariaDB tutorial explains how to use the MariaDB LOG2 function with syntax and examples.

Description

The MariaDB LOG2 function returns the base-2 logarithm of a number.

Syntax

The syntax for the LOG2 function in MariaDB is:

LOG2( number )

Parameters or Arguments

number
The number to take the base-2 logarithm of. Must be greater than 0.

Note

  • The LOG2 function will return NULL, if number is less than or equal to 0.
  • See also the LOG function.

Applies To

The LOG2 function can be used in the following versions of MariaDB:

  • MariaDB 10

Example

Let's look at some MariaDB LOG2 function examples and explore how to use the LOG2 function in MariaDB.

For example:

SELECT LOG2(0.7);
Result: -0.5145731728297583

SELECT LOG2(3);
Result: 1.5849625007211563

SELECT LOG2(3.25);
Result: 1.7004397181410922

SELECT LOG2(0);
Result: NULL