# log2(3) [plan9 man page]

LOG2(3) Linux Programmer's Manual LOG2(3)NAME

log2, log2f, log2l - base-2 logarithmic functionSYNOPSIS

#include <math.h> double log2(double x); float log2f(float x); long double log2l(long double x); Link withFeature Test Macro Requirements for glibc (see feature_test_macros(7)): log2(), log2f(), log2l(): _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L-lm.DESCRIPTION

These functions return the base 2 logarithm of x.RETURN VALUE

On success, these functions return the base 2 logarithm of x. For special cases, including where x is 0, 1, negative, infinity, or NaN, see log(3).ERRORS

See math_error(7) for information on how to determine whether an error has occurred when calling these functions. For a discussion of the errors that can occur for these functions, see log(3).VERSIONS

These functions first appeared in glibc in version 2.1.ATTRIBUTES

For an explanation of the terms used in this section, see attributes(7). +-------------------------+---------------+---------+ |Interface | Attribute | Value | +-------------------------+---------------+---------+ |log2(), log2f(), log2l() | Thread safety | MT-Safe | +-------------------------+---------------+---------+CONFORMING TO

C99, POSIX.1-2001, POSIX.1-2008. The variant returning double also conforms to SVr4, 4.3BSD.SEE ALSO

cbrt(3), clog2(3), log(3), log10(3), sqrt(3)COLOPHON

This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. 2017-09-15 LOG2(3)

## Check Out this Related Man Page

log2(3M) Mathematical Library Functions log2(3M)NAME

log2, log2f, log2l - compute base 2 logarithm functionsSYNOPSIS

c99 [ flag... ] file...[ library... ] #include <math.h> double log2(double x); float log2f(float x); long double log2l(long double x);-lmDESCRIPTION

These functions compute the base 2 logarithm of their argument x, log2(x).RETURN VALUES

Upon successful completion, these functions return the base 2 logarithm of x. If x is +-0, a pole error occurs and log2(), log2f(), and log2l() return,-HUGE_VAL, and-HUGE_VALF, respectively. For finite values of x that are less than 0, or if x is-HUGE_VALLa domain error occurs and a NaN is returned. If x is NaN, a NaN is returned. If x is 1, +0 is returned. If x is +Inf, x is returned.-InfERRORS

These functions will fail if: Domain Error The finite value of x is less than 0, or x isIf the integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, then the invalid floating-point exception is raised. Pole Error The value of x is 0. If the integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, then the divide-by-zero floating-point exception is raised.-Inf.USAGE

An application wanting to check for exceptions should call feclearexcept(FE_ALL_EXCEPT) before calling these functions. On return, if fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an exception has been raised. An application should either examine the return value or check the floating point exception flags to detect exceptions.ATTRIBUTES

See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+SEE ALSO

feclearexcept(3M), fetestexcept(3M), log(3M), math.h(3HEAD), attributes(5), standards(5)SunOS 5.1112 Jul 2006 log2(3M)