Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/numeric/bit floor"

From cppreference.com
< cpp‎ | numeric
m
m (T. Canens moved page cpp/numeric/floor2 to cpp/numeric/bit floor: Text replace - "(ceil|floor)2" to "bit_$1")

Revision as of 05:00, 21 February 2020

 
 
 
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 participates in overload resolution only 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