I am trying to understand the difference of vocabulary used in the C++ language between digits and bits as in :
CHAR_BIT;
std::numeric_limits<char>::digits;
Is there a conceptual difference? Maybe for weird architectures?
If so, what would be called the result of the operator[] of std::bitset. Does it give access to a bit or to a digit?
And the current documentation of boost does not help: cppint provides a code with Digits but the documentation mention Bits (this is obviously a problem with the documentation, but I don't know whether the text or the code is more recent.)
From this
std::numeric_limits::digitsreference:And later it states that for
charthe result isCHAR_BIT - std::numeric_limits<char>::is_signed.And from the C numeric limits reference:
So for a normal modern computer, where
charis eight bits, thenCHAR_BITSis equal to8and thedigitsfunction will return either7or8depending on ifcharis signed or not.I agree that the using the word "digits" is is kind of confusing when getting the number of bits in an integer type, but it makes much more sense for floating point types:
And
std::bitsetis a set of bits, so the indexing operator will give you the selected bit in the set.