Integer variables can be divided into the following categories:
1. basic type
The type specifier is int, which may occupy 2 or 4 bytes of memory (usually on 16-bit computer and 32-bit computer respectively) according to the internal word length and compiler version of the computer, and its value is a basic integer constant.
2. Short integers
The type specifier is short int or short, occupying 2 bytes of memory, and its value is short integer constant.
3. Long integers
The type specifier is long int or long, occupying 4 bytes of memory, and its value is long integer constant.
4.64-bit integer (non-ANSI standard)
The type specifier is __int64, long long int or long long, which occupies 8 bytes of memory and takes a value of 64-bit integer constant.
5. Unsigned types
The type specifier is unsigned. You can use an unsigned int alone or as a prefix, both of which represent unsigned integers, that is, integer variables that are always non-negative, and the data range greater than 0 is about twice as large as the original. Various unsigned types occupy the same number of bytes in memory space as the corresponding signed types. However, because the sign bit is omitted, it cannot represent a negative number. The following table lists the number of memory bytes allocated by various integer quantities in Turbo C and the representation range of this number.
Integer suffix
You can use the suffix "l" or "l" to represent long integers. For example:
Decimal long integers: 158L (decimal 158) and 358000L (decimal 358000);
Octal long integer: 0 12L (decimal 10), 077L (decimal 63), 0200000L (decimal 65536);
Hexadecimal long integers: 0X 15L (decimal 2 1), 0XA5L (decimal 165), 0X 10000L (decimal 65536).
There is no numerical difference between the long integer 158L and the basic integer 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, only 2 bytes of storage space are allocated. So pay attention to the operation and output format to avoid mistakes.
Unsigned numbers can also be represented by suffixes, and the suffix of unsigned numbers of integers 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.