SQLite log2() Function

The SQLite log2() function returns the base 2 logarithm for the number specified by the parameter.

Syntax

Here is the syntax of the SQLite log2() function:

log2(numeric_value)

Parameters

numeric_value

Required. A number whose logarithm needs to be obtained.

Return value

The SQLite log2() function returns the base 2 logarithm for numeric_value.

The SQLite log2() function will return NULL if the parameter is NULL.

The SQLite log2() function will return NULL if the parameter is zero.

The SQLite log2() function will return NULL if the parameter is negative.

The SQLite log2() function will return NULL if the parameter is not numeric.

Examples

This example shows the basic usage of the SQLite log2() function:

SELECT
    log2(1),
    log2(2),
    log2(3.3);
  log2(1) = 0.0
  log2(2) = 1.0
log2(3.3) = 1.72246602447109