Consider the below java code.
Integer value = Integer.MIN_VALUE;
System.out.println(value);
value = -value;
System.out.println(value);
Output
-2147483648
-2147483648
How the negative value of Integer.MIN_VALUE
value results the same value?
However the result can't be 2147483648
because the maximum value of Integer in java is 2147483647
.
But want to know why -2147483648
? What kind of bit-wise operations are happening internally?