Talk:C++ Programming/Programming Languages/C++/Code/Statements/Variables/Type/Data Types

Shouldn't the "magic numbers" (127, -32767, etc.) in this document be replaced with their constants from limits.h (SCHAR_MAX, SHRT_MIN, etc.)? --12.9.179.117 18:30, 26 February 2007 (UTC)


 * Magic number should be avoided but we don't have a list of default values, the standard (2003) only mentions of reserved identifiers from the C library, personally I don't know if the values one expects them to represent are fixed (consider for instance http://msdn.microsoft.com/en-us/library/296az74e(VS.71).aspx it states that that list is Microsoft Specific). --Panic (talk) 03:50, 17 September 2008 (UTC)

Less or More?
I have made a change to the Data Types table. The original text was: "Any encoding of 8 bits or less (e.g. ASCII) can be used to store characters". I have changed it to read: " Any encoding of 8 bits or more ...", since that is what the previous column in the table would suggest. Was the wording simply incorrect, or did I miss the point of that line? – e James  (talk) – 22:34, 16 September 2008 (UTC)


 * I've restored to the prev. edit, the intention expressed is that char is only guaranteed to have 8 bits (it may indeed hold more in specific setups, compiler and OS).  --Panic (talk) 03:32, 17 September 2008 (UTC)

==== There seems to be confusion over the two words char and character. C++11 (Draft): "The fundamental storage unit in the C++ memory model is the byte. A byte is at least large enough to contain any member of the basic execution character set (2.3) and the eight-bit code units of the Unicode UTF-8 encoding form and is composed of a contiguous sequence of bits, the number of which is implementation defined. ... The memory available to a C++ program consists of one or more sequences of contiguous bytes. Every byte has a unique address." So a byte is 8 bits OR MORE and a char is one byte OR MORE. I am changing the table. I am also removing "sizeof" it is a great idea to have it on this page, but not in the table. 71.31.146.16 (discuss) 22:50, 10 June 2012 (UTC)
 * gives the size in units of chars. These "bytes" need not be 8-bit bytes (though commonly they are); the number of bits is given by the CHAR_BIT macro in the climits header.