What is the range of int in c language?

烟雨青岚
Release: 2020-07-03 11:19:29
Original
34912 people have browsed it

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

What is the range of int in c language?

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template