Values of int type require 32 bits (4 bytes) of memory. It means that there are 232 different possible values of int variable. Half of them are positive and half are negative. Numbers with a higher-order bit equal to one are considered to be negative:
00000000 00000000 00000000 000000002 = 010
00000000 00000000 00000000 000000012 = 110
. . .
01111111 11111111 11111111 111111112 = 214748364710 = 231–1
10000000 00000000 00000000 000000002 = –214748364810 = –231
. . .
11111111 11111111 11111111 111111112 = –110
Therefore, in the process of a loop execution a -2147483648 number will follow after a 2147483647 number. Since it does not satisfy the cycle continuation condition, program will exit the loop.
Login in to like
Login in to comment