The following numbers are legal octal numbers:
0 15 (decimal13) 010/(decimal 65)0 177777 (decimal 65535)
The following numbers are not legal octal numbers:
256 (without prefix 0) 0382 (including non-octal digits) -0 127 (negative sign appears)
2. Hexadecimal integer constant
Hexadecimal integer constants are prefixed with 0X or 0x. Its numerical values are 0~9, A~F or a ~ f.
The following numbers are legal hexadecimal integer constants:
0X2A (42 in decimal 42) 0XA0 (decimal 160)0x ffff (decimal 65535)
The following numbers are not legal hexadecimal integer constants:
5A (without prefix 0X) 0X3H (including non-hexadecimal digits)
3. Decimal integer constant
Decimal integer constants have no prefix. Its number is 0 ~ 9.
The following numbers are legal decimal integer constants:
237 -568 65535 1627
The following numbers are not legal decimal integer constants:
023 (without leading 0) 23D (including non-decimal digits)
In the program, all kinds of decimal numbers are distinguished by prefixes. Therefore, when writing constants, don't get the prefix wrong, which will lead to incorrect results. For example, the initial value of the array int power _ of _10 [4] = {0001,00 10, 0 1000} will be interpreted as {1 000}.
4. suffix of integer constant
On a machine with a word length of 16 bits, the length of the basic integer is also 16 bits, so the range of the number represented is also limited. Decimal unsigned integer constants range from 0 to 65535, and signed numbers range from -32768 to +32767. The range of octal unsigned number is 0 ~ 0 177777. The expression range of hexadecimal unsigned number is 0x0 ~ 0xffff or 0x0 ~ 0xffff. If the number used exceeds the above range, it must be expressed as a long integer. Long integers are denoted by the suffix "l" or "l". For example:
Decimal long integer constant 158L (decimal 158) 358000L (decimal -358000)
Octal long integer constant 0 12L (decimal 10) 077L (decimal 63) 0200000L (decimal 65536)
Hexadecimal long integer constant 0X 15L (decimal 2 1)0xA5l (decimal 165)0x 10000 l (decimal 65536).
There is no numerical difference between the long integer 158L and the basic integer constant 158. But for 158L, because it is a long integer, the C compiler system will allocate 4 bytes of storage space for it. For 158, because it is a basic integer, 2 or 4 bytes of storage space is allocated according to the internal word length of the computer and the compiler version. So pay attention to the operation and output format to avoid mistakes. For large numbers that cannot be represented by long integers, some compilers stipulate that they can be represented by 64-bit integer constants with the suffix "LL" or "ll". Sometimes because of special needs, short integers may need to be specially marked. Only some compilers support the suffix "s" or "s" for short integers. Unsigned numbers can also be represented by suffixes, and the suffix of unsigned numbers with integer constants is "u" or "u". For example, 358u, 0x38au and 235lu are all unsigned numbers. Prefixes and suffixes can be used to represent different types of numbers at the same time. For example, 0XA5Lu represents a hexadecimal unsigned long integer A5, and its decimal number is 165.