Here I would like to mention the concept of integer hours. Maximum and minimum values for int in java: int MAX_VALUE = 2147483647 int MIN_VALUE = -2147483648
check the following results.
int a = 2147483645;
for(int i=0;i<10;i++) {
System.out.println("a:"+ a++);
}
Conclusion:
a:2147483645
a:2147483646
a:2147483647
a:-2147483648
a:-2147483647
a:-2147483646
a:-2147483645
a:-2147483644
a:-2147483643
a:-2147483642
This shows that when you go beyond the + ve range of an integer, the following values start again with a negative initial value.
-2147483648, <-----------------
-2147483647, |
-2147483646, |
. |
. |
. | (next value will go back in -ve range)
0, |
+1, |
+2, |
+3, |
. |
. |
., |
+2147483645, |
+2147483646, |
+2147483647 ---------------------
13, 6227020800.
java.
,
6227020800
- 2147483647 (+ve max value)
-----------------
Value = 4079537153
- 2147483648 (-ve max value)
-----------------
value = 1932053505
- 1 (for zero in between -ve to +ve value)
----------------
Answer = 1932053504
, 13 1932053504.
.
.
.