std::log2p1
| Defined in header <bit>
|
||
| template< class T > constexpr T log2p1(T x) noexcept; |
(since C++20) | |
If x is not zero, calculates the number of bits needed to store the value x, that is, 1 + floor(log
2(x)). If x is zero, returns zero.
This overload only participates in overload resolution if T is an unsigned integer type (that is, unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long, or an extended unsigned integer type).
Contents |
[edit] Return value
Zero if x is zero; otherwise, one plus the base-2 logarithm of x, with any fractional part discarded.
[edit] Notes
This function is equivalent to return std::numeric_limits<T>::digits - std::countl_zero(x);.
[edit] Example
| This section is incomplete Reason: no example |
[edit] See also
| (C++20) |
counts the number of consecutive 0 bits, starting from the most significant bit (function template) |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
