---
layout: doc
title: general / log2
---
# log2

### NAME

    log2() - return the base 2 logarithm of a number

### SYNOPSIS

    float log2( float | int x );

### DESCRIPTION

    Returns the base 2 logarithm of x.  The argument may be an int or a
    float, and the return value is always a float.

    The value of x must be greater than 0.0.  If x is less than or equal to
    0.0, an error is raised.

### SEE ALSO

    log(3), log10(3), exp(3), pow(3)
