Namespaces
Variants
Views
Actions

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

From cppreference.com
< cpp‎ | numeric
m (T. Canens moved page cpp/numeric/ceil2 to cpp/numeric/bit ceil: Text replace - "(ceil|floor)2" to "bit_$1")
m (Text replace - "(ceil|floor)2" to "bit_$1")
Line 1: Line 1:
{{cpp/title|ceil2}}
+
{{cpp/title|bit_ceil}}
 
{{cpp/numeric/navbar}}
 
{{cpp/numeric/navbar}}
 
{{ddcl|since=c++20|header=bit|
 
{{ddcl|since=c++20|header=bit|
 
template< class T >
 
template< class T >
constexpr T ceil2(T x);
+
constexpr T bit_ceil(T x);
 
}}
 
}}
  

Revision as of 05:02, 21 February 2020

 
 
 
Defined in header <bit>
template< class T >
constexpr T bit_ceil(T x);
(since C++20)

Calculates the smallest integral power of two that is not smaller than x. If that value is not representable in T, the behavior is undefined.

This function is constexpr only if the result is representable in T.

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).

Contents

Parameters

x - values of unsigned integer type

Return value

The smallest integral power of two that is not smaller than x.

Exceptions

(none)

Example