bit_width_constexpr#
Fully qualified name: carb::cpp::bit_width_constexpr
Defined in carb/cpp/Bit.h
-
template<class T>
constexpr int carb::cpp::bit_width_constexpr( - T val,
Returns the number of bits needed to store
val
, or 0, ifval
is 0.Same as 1 + floor(log2(x)).
Note
Unlike bit_width(), this function is
constexpr
as it does not make use of intrinsics. Therefore, at runtime it is recommended to use bit_width() instead of this function.- Template Parameters:
T – An unsigned integral type
- Parameters:
val – An unsigned integral value
- Returns:
The number of bits needed to store
val