can someone explain how does the range for int comes out to be -2^{31} to (2^{31}-1)...i mean , we can also fit 2^{31} inside this range....???? why -1 ????
Printable View
can someone explain how does the range for int comes out to be -2^{31} to (2^{31}-1)...i mean , we can also fit 2^{31} inside this range....???? why -1 ????
Welcome datus
0 offset the balance on the positive side
Read about 2's compliment
Hello.
Java uses 2's complement representation for storing numbers.
And an integer occupies 4 bytes of memory.
With this much knowledge just spend some time on how to store signed numbers using 2's complement. You should be able to get the range.
Syed.