std::floor2
Defined in header <bit> | ||
|---|---|---|
template< class T > constexpr T floor2(T x) noexcept; | (since C++20) |
If x is not zero, calculates the largest integral power of two that is not greater than 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).
Return value
Zero if x is zero; otherwise, the largest integral power of two that is not greater than x.
Example
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/numeric/floor2