|
Declaration procedures specific to the type of integer variables tell the C ++ compiler, the compiler knows how to type it constant? Assuming constant in a program to represent a number:
Cout << "year =" << 1492 << "\ n";
1492 program will be stored as int, long, or other cosmetic it? The answer is that, unless there is reason to store other types (such as using a special suffix to represent a specific type, or too much, can not be stored as int), otherwise c ++ will be stored as an integer constant of type int.
First look suffix. Suffix is placed after the number of constants letter indicates the type. Integer behind l or L suffix indicates that a long integer constant, u or U suffix unsigned int constant, ul (you can use any kind of order, uppercase lowercase) indicates unsigned long constants (due lowercase l looks like 1, Therefore, you should use as a capital L suffix). For example, in a 16-bit int, long for the 32-bit systems, digital 22022 is stored as int, accounting for 16, is stored as digital 22022L long, accounting for 32. Similarly, 22022LU and 22022UL are stored as unsigned long.
Next, study length. In c ++, the rules adopted by a decimal integer, hexadecimal and octal is slightly different. For decimal integer without the suffix, using the following types can be stored in the minimum number to represent the type: int, long, or unsigned long. On a 16-bit int, long 32-bit computer system, 20,000 are represented int type, long type is represented as 40,000, 3 billion is represented as unsigned long type. For hexadecimal or octal integer without the suffix, using the following types can be stored in the minimum number to represent the type int, unsigned int, long, or unsigned long. In the long represented as 40,000 computer system, hexadecimal number 0x9C40 (40000) will be represented as unsigned int. This is because the hex used to represent a memory address, and memory address is unsigned, therefore, unsigned int fit to represent more than the long 16-bit address. |
|
|
|