##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::log2

From cppreference.com
< cpp‎ | numeric‎ | math

Defined in header `<cmath>` |  |
float log2( float arg ); |  | (since C++11)
double log2( double arg ); |  | (since C++11)
long double log2( long double arg ); |  | (since C++11)
double log2( Integral arg ); |  | (since C++11)

Computes the base 2 logarithm of arg.

### [edit] Parameters

arg | - | value of floating-point or Integral type

### [edit] Return value

log
2(arg)

Domain error occurs if `arg` is negative. NAN is returned in that case.

Range error occurs if `arg` is ​0​. -HUGE_VAL is returned in that case.

### [edit] See also

log | computes natural (base e) logarithm (to base e) (ln(x)) (function) [edit]
exp2 (C++11) | returns 2 raised to the given power (2x) (function) [edit]
log10 | computes common (base 10) logarithm (log10(x)) (function) [edit]
C documentation for log2

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/numeric/math/log2&oldid=67129"