Home >Java >javaTutorial >What is the length of java int

What is the length of java int

(*-*)浩
(*-*)浩Original
2019-12-13 14:59:2911090browse

What is the length of java int

int:

int The data type is a 32-bit, signed integer expressed in two's complement; (Recommended learning: javacourse)

The minimum value is -2,147,483,648 (-2^31);

The maximum value is 2,147,483,647 (2^31 - 1);

General Integer variables default to int type;

The default value is 0;

Example:

int a = 100000, int b = -200000。

1, For positive numbers Say, its complement is itself.

2, For a negative number, its complement is the inversion of all the bits of the binary number of the corresponding positive number plus one.

3, The same operation is used to find the original code from the complement of a negative number (all bits are inverted by 1), which is the absolute value of the negative number

int It is 4 bytes, 32 bits,

10000000 00000000 00000000 00000000 is the complement code, the first bit is the sign bit, 1 represents a negative number, so

negates the remaining bits, and the result It is 1111111 11111111 11111111 11111111. After adding one, it is 10000000 00000000 00000000 00000000

4. So the original code refers to -2^31=-2147483648

The above is the detailed content of What is the length of java int. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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