Why is there another negative int than a positive int?

The upper limit for any data type int(excluding tinyint) is always one less than the absolute value of the lower limit.

For example, the upper limit for intis 2,147,483,647 and ABS (lower limit) = 2,147,483,648.

Is there a reason why there is always another negative int than a positive int?

EDIT: Changed since the question is not directly related to

+4
source share
2 answers

, , . (8 ). 1 2^8, 256 .

( 128).

0 +0 -0. 0.

, -128..-1..0..1..127.

16/32/64-bit.

EDIT:

-128 to 127?

, represent signed integer:

+4

.

lad2025, . , 0, . , , : " , ?"

, . n - 1 , 0 1 . , +0 -0. .

, . ( .) , , . . +1 001, -1 111. . 1 .

100 ( ). , . , 1 , (011 → 100). "" " ". .

+2

Source: https://habr.com/ru/post/1615802/


All Articles