Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What exactly does an integer variable mean in C language?
What exactly does an integer variable mean in C language?
Shaping in C language is a basic technical term in computer, which refers to data without decimal parts. Integer values can be specified with decimal, hexadecimal, or octal symbols and can start with an optional symbol (-or+). If octal symbols are used, numbers must be preceded by 0 (zero) and hexadecimal symbols must be preceded by 0x.

In C language, integer includes integer constants and integer variables, and integer variables include short integer, basic integer and long integer, which are divided into signed and unsigned versions. It is an intelligent calculation method.

The values of integer variables can be decimal, octal and hexadecimal, but binary numbers are stored in memory. Variables, as the name implies, are variables whose values can be changed, and integer variables represent integer data.

Extended data:

Integer constant classification

1, octal integer constant: it must start with 0, that is, 0 is used as the prefix of octal number. Digital value is 0 ~ 7. Octal numbers are usually unsigned numbers. The following numbers are legal octal numbers:

0 15 (decimal13) 010/(decimal 65)0 177777 (decimal 65535).

2. Hexadecimal integer constant: The prefix of hexadecimal integer constant is 0X or 0x. Its numerical values are 0~9, A~F or a ~ f. The following numbers are legal hexadecimal integer constants:

0X2A (42 decimal 42) 0XA0 (160 decimal) 0xffff (65535 decimal).

3. Decimal integer constant: Decimal integer constant has no prefix. Its number is 0 ~ 9. The following numbers are legal decimal integer constants:

237 -568 65535 1627

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.

Integer variable classification

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. 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.

Baidu Encyclopedia-Integer (Computer Language)