The value range of int in C language is: "-2147483648 ~ 2147483647". The int type occupies 4 bytes in C language, that is, 32 binary bits; when representing a positive number, the highest bit is the sign bit (0); when representing a negative number, the highest bit is the sign bit (1).
The value range of int in C language is: -2147483648 ~ 2147483647
The explanation is as follows:
The int type occupies 4 bytes in C language, which is 32 binary bits.
When representing a positive number, the highest bit is the sign bit (the sign bit is 0), and the largest positive number is 0111 1111 1111 1111 1111 1111 1111 1111, that is, 2^31 -1 = 2147483647
When representing a negative number, the highest bit is the sign bit (the sign bit is 1), and the smallest negative number is 1000 0000 0000 0000 0000 0000 0000 0000. In the computer, it is stored in the form of complement. The C language stipulates 1000 0000 0000 0000 The complement of 0000 0000 0000 0000 is -2147483648
So the value range of int in C language is: -2147483648 ~ 2147483647
Recommended tutorial: "C Language》
The above is the detailed content of What is the range of int in c language?. For more information, please follow other related articles on the PHP Chinese website!