The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

log2, log2f, log2l

Visual Studio 2015

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on

The latest version of this topic can be found at log2, log2f, log2l.

Determines the binary (base-2) logarithm of the specified value.

double log2(  
   double x  
float log2(  
   float x  
); //C++ only  
long double log2(  
   long double x  
); //C++ only  
float log2f(  
   float x  
long double log2l(  
   long double x  


[in] x
The value to determine the base-2 logarithm of.

On success, returns return log2 x.

Otherwise, may return one of the following values:

x < 0NaN
x = 1+0
domain errorNaN
pole error-HUGE_VAL, -HUGE_VALF, or -HUGE_VALL

Errors are reported as specified in _matherr.

If x is an integer, this function essentially returns the zero-based index of the most significant 1 bit of x.

FunctionC headerC++ header
log2, log2f, log2l<math.h><cmath>

For additional compatibility information, see Compatibility.

Alphabetical Function Reference
exp2, exp2f, exp2l
log, logf, log10, log10f