[edit] numeric limits


It's tempting to write -128 here, but the Standard-guaranteed numeric_limits<signed char>::min() (and SCHAR_MIN) is -127, even if every implementation uses -128 (the reason is that the Standard supports 2's complement, 1's complement, and Sign-and-magnitude representations of negatives). Same for all other mins.
Reference:[numeric.limits.members] which refers to 18.3.3[c.limits]/2 which refers to ISO 9899:1999

Even if the Standard defines generalized limits, it still would be a good idea to stick to the data models and report what actual limits the implementations have, not what the Standard defines. For example, the Standard defines neither the format nor the limits for the floating point types, but what the actual implementations provide is still a relevant fact. That's not to say that the odd lower limit for the signed integers should not be mentioned. P12 07:48, 24 September 2011 (PDT)

True.. and considering there's probably no C++ compilers for one's compl and sign-and-magnitude machines, maybe it should even give the usual 2's comp in the table and mention the standard guarantees in a note. --Cubbi 08:40, 24 September 2011 (PDT)

[edit] size hierarchy

This edit seems to have gotten lost, I think it's a pretty important guarantee -- otherwise, as the page is written now, with "at least" limits only, int could be bigger than long. --Cubbi 08:47, 24 September 2011 (PDT)

[edit] C++ standard bit numbers

Does the C++ standard really guarantee certain bit number minimums as the table shows? If not, where did those numbers come from? I've seen them on Wikipedia too but I haven't found a reference in the standard. Pubby 01:51, 15 May 2012 (PDT)

It guarantees that the types are able to represent every value from a given range ([-127, +127] for signed char, for example). It doesn't directly say that char is at least 8 bits, but you can't represent that many distinct values with less than 8. --Cubbi 05:48, 15 May 2012 (PDT)
Do you happen to have a reference for where the standard makes claims about required ranges? The closest I've been able to find so far is 3.9.1 (which might be interpreted to say something about the storage requirements for int) but I haven't found anything else. --Nate 07:06, 15 May 2012 (PDT)[numeric.limits.members] which refers to 18.3.3[c.limits]/2 which refers to ISO 9899:1999 (oh, actually char is the one type where the number of bits is specified explicitly: no less than 8) --Cubbi 07:52, 15 May 2012 (PDT)
Got it. Thanks Cubbi.  :) --Nate 13:58, 15 May 2012 (PDT)

[edit] introduction of long long minimum bit lengths

The page says, "long long - target type will have width of at least 64 bits. (since C++11)". I may simply be confused as to the implication, but at least per Wikipedia long long was introduced in C++99. Is the issue that it was introduced but there was no guarantee of the minimum until C++11, or should the page be changed to say "since C++99"? Proxyma (talk) 14:28, 17 May 2015 (PDT)

It was introduced in the C programming language in C99. It was then introduced in C++ in C++11 (technically in TR1) --Cubbi (talk) 21:31, 17 May 2015 (PDT)

[edit] Size of char like types

This should be mentiond like the numeric types. I think the size of char is 1 byte and of wchar_t is 2 on Windows and 4 on Unix. 02:03, 7 October 2015 (PDT)

the page does say "1 == sizeof(char)" right under the integer type properties table and explictly talks about sizes of signed and unsigned chars in the value ranges table. wchar_t needs a few more words, you're right. Added. --Cubbi (talk) 05:53, 7 October 2015 (PDT)