boost - C++: digits vs bits? -
i trying understand difference of vocabulary used in c++ language between digits , bits in :
char_bit; std::numeric_limits<char>::digits; is there conceptual difference? maybe weird architectures? if so, called result of operator[] of std::bitset. give access bit or digit?
and current documentation of boost not help: cppint provides code digits documentation mention bits (this problem documentation, don't know whether text or code more recent.)
from this std::numeric_limits::digits reference:
the value of std::numeric_limits::digits number of digits in base-radix can represented type t without change. integer types, number of bits not counting sign bit.
and later states char result char_bit - std::numeric_limits<char>::is_signed.
and c numeric limits reference:
char_bitnumber of bits in byte
so normal modern computer, char 8 bits, char_bits equal 8 , digits function return either 7 or 8 depending on if char signed or not.
i agree using word "digits" is kind of confusing when getting number of bits in integer type, makes more sense floating point types:
for floating-point types, number of digits in mantissa.
and std::bitset set of bits, indexing operator give selected bit in set.
Comments
Post a Comment