Home > Common Problem > body text

What is the value range of int32?

青灯夜游
Release: 2020-11-04 11:17:29
Original
49684 people have browsed it

The value range of int32 is "-2147483648" to "2147483647"; while the value range of int64 is "-9223372036854775808" to "9223372036854775808".

What is the value range of int32?

The value range of int32

The range of 32-bit int type variables in the computer , where type int is a signed integer.

Positive numbers are expressed as original codes in the computer, and the highest bit is the sign bit: The original code of

1 is the original code of 0000 0000 0000 0000 0000 0000 0000 0001

2147483647 The code is 0111 1111 1111 1111 1111 1111 1111 1111

So the largest positive integer is 2147483647

Negative numbers are represented as complement codes in the computer, and the highest bit is the sign bit:

-1:

The original code is 1000 0000 0000 0000 0000 0000 0000 0001, the inverse code of

is 1111 1111 1111 1111 1111 1111 1111 1110, the complement code of

is 1111 1111 1111 1111 1111 1111 1111 1111

-2147483647: The original code of

is 1111 1111 1111 1111 1111 1111 1111 1111, the reverse code of

is 1000 0000 0000 000 0 0000 0000 0000 0000 ,

The complement is 1000 0000 0000 0000 0000 0000 0000 0001

So the smallest negative number is -2147483647? Wrong, no.

In binary, there are two table methods for 0.

The original code of 0 is 0000 0000 0000 0000 0000 0000 0000 0000, the original code of

-0 is 1000 0000 0000 0000 0000 0000 0000 0000,

because 0 is only One is needed, so use -0 as the smallest number -2147483648. The complement code of

-2147483648 is expressed as 1000 0000 0000 0000 0000 0000 0000 0000. There is no original code in 32 bits.

Note that this complement is not the real complement. The real complement is 1 1000 0000 0000 0000 0000 0000 0000 0000, which is an overflow.

So the signed 32-bit int type integer is -2147483648~2147483647

Explanation:

int range -2,147,483,648 to 2,147,483,647

int16 - Numeric range: -32768 to 32767

int32 - Numeric range: -2,147,483,648 to 2,147,483,647

int64 - Numeric range: -9223372036854775 808 to 9223372036854775808

For more programming-related knowledge, please visit: Programming Learning Course! !

The above is the detailed content of What is the value range of int32?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
int
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!