Computes base 2 logarithm.
#include <math.h>
double log2 (x)
double x;
float log2f (x)
float x;
long double log2l (x)
long double x;
_Decimal32 log2d32 (x)
_Decimal32 x;
_Decimal64 log2d64 (x)
_Decimal64 x;
_Decimal128 log2d128 (x)
_Decimal128 x;
The log2, log2f, log2l, log2d32, log2d64, and log2d128 subroutines compute the base 2 logarithm of the x parameter, log2 (x).
An application wishing to check for error situations should set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these subroutines. Upon return, if errno is nonzero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is nonzero, an error has occurred.
Item | Description |
---|---|
x | Specifies the value to be computed. |
Upon successful completion, the log2, log2f, log2l, log2d32, log2d64, and log2d128 subroutines return the base 2 logarithm of x.
If x is ±0, a pole error occurs and the log2, log2f, log2l, log2d32, log2d64, and log2d128 subroutines return -HUGE_VAL, -HUGE_VALF, -HUGE_VALL, -HUGE_VAL_D32, -HUGE_VAL_D64, and -HUGE_VAL_D128 respectively.
For finite values of x that are less than 0, or if x is -Inf, a 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.