numeric_limits<char>::digits = 7 ?

R. Sinoradzki sinoradz@student.uni-kl.de
Thu May 3 09:42:00 GMT 2001


Oh, thanks. 

I did not know that.
I got it wrong because my Stroustrup 3rd edition
(german) says in an implementation example:

class numeric_limits<char>
{
public:
   static const bool is_specialized = true;
   static const int digits = 8;
   static bool is_signed = true;
   ...
}

and I thought this is a typical implementation. It's
perhaps a good idea to look at the ISO-standard
when I use something for the time :)

bye, Ralf

Gabriel Dos Reis wrote:
> 
> "R. Sinoradzki" <sinoradz@student.uni-kl.de> writes:
> 
> | Hi,
> |
> | I want to use a bitset to store a double.
> |
> | So I tried bitset< numeric_limits<char>::digits * sizeof(double) >.
> |
> | Then I noticed, that numeric_limits<char>::digits is set to 7.
> | This is different from CHAR_BIT = 8 in <climits>.
> | What is the reason to use different values?
> 
> For T = builtin-type, numeric_limits<T>::digits the number of non-sign
> bits in the representation.  See 18.2.1.2/7.
> 
> For example std::numeric_limits<unsigned char>::digits is 8.
> 
> -- Gaby



More information about the Libstdc++ mailing list