std::floor2

来自cppreference.com
< cpp‎ | numeric
定义于头文件 <bit>
template< class T >
constexpr T floor2(T x) noexcept;
(C++20 起)

x 非零,则计算不大于 x 的最大的二的整数次幂。若 x 为零,则返回零。

此重载仅若 T 为无符号整数类型(即 unsigned charunsigned shortunsigned intunsigned longunsigned long long 或扩展无符号整数类型)才参与重载决议。

返回值

x 为零则为零;否则为不大于 x 的最大的二的整数次幂。

示例