CHAR_BIT
defines the number of bits per character. But it is an old macro. Similar macros have been replaced in recent C++ standards.
Is there a more modern replacement for CHAR_BIT
in C++11/14/17?
CHAR_BIT
defines the number of bits per character. But it is an old macro. Similar macros have been replaced in recent C++ standards.
Is there a more modern replacement for CHAR_BIT
in C++11/14/17?
The number of non-sign bits is provided by std::numeric_limits<T>::digits
, so it can be determined by:
std::numeric_limits<unsigned char>::digits
Note the use of the unsigned
qualifier to ensure there are no sign bits.