Fundamental types Objects declared as characters (char) shall be large enough to store any member of the implementation’s basic character set. If a character from this set is stored in a character object, the integral value of that character object is equal to the value of the single character literal form of that character. It is implementation defined whether a char object can hold negative values. Characters can be explicitly declared unsigned or signed. Plain char, signed char, and unsigned char are three distinct types. A char, a signed char, and an unsigned char occupy the same amount of storage and have the same alignment requirements that is, they have the same object representation. For character types, all bits of the object representation participate in the value representation. For unsigned character types, all possible bit patterns of the value representation represent numbers. These requirements do not hold for other types. In any particular implementation, a plain char object can take on either the same values as a signed char or an unsigned char; which one is implementation-defined. There are four signed integer types: signed char, short int, int, and long int. In this list, each type provides at least as much storage as those preceding it in the list. Plain ints have the natural size suggested by the architecture of the execution environment ; the other signed integer types are provided to meet special needs. For each of the signed integer types, there exists a corresponding (but different) unsigned integer type: unsigned char, unsigned short int, unsigned int, and unsigned long int, each of which occupies the same amount of storage and has the same alignment requirements as the corresponding signed integer type ; that is, each signed integer type has the same object representation as its corresponding unsigned integer type. The range of nonnegative values of a signed integer type is a subrange of the corresponding unsigned integer type, and the value representation of each corresponding signed/unsigned type shall be the same. Unsigned integers, declared unsigned, shall obey the laws of arithmetic modulo 2n where n is the number of bits in the value representation of that particular size of integer. |
If the size of the data types vary from computer to computer, how would I know which one to use? |
size of char has not changed as far as I can remember (8bits). |
Integers have changed from 16 bits to 32 bit and now will (soon) be 64 bits. |