# Integer.MIN_VALUE????

Amit Das

Ranch Hand

Posts: 206

Edwin Dalorzo

Ranch Hand

Posts: 961

posted 11 years ago

Let's see a sample:

Let's suppose that an integer insted of 32 bits has 4 bits. If it were unsigned it would be 2^3 = 8; but as it is unsigned we need to reserve a bit. That's to say 2^3-1 = 7 for positive and 2^3 = 8 for negative. Let's see why:

See we cannot represent the 8 because it would be using the bit sign. Now let's see the negatives.

Notice that negative numbers have the sign bit on. And that's why they can represent on more decimal number. Notice that the value of MIN_VALUE in this case is formed with all bits set to 0, but the sign bit. That is why the MIN_VALUE in interger is 80000000 and the one that you said is -1, because it has all the bits set to 1, that's to say ffffffff.

Remember that you obtain a negative number by means of negating the bits of the positive one and then adding one.

[ May 15, 2005: Message edited by: Edwin Dalorzo ]

[ May 15, 2005: Message edited by: Edwin Dalorzo ]

Let's suppose that an integer insted of 32 bits has 4 bits. If it were unsigned it would be 2^3 = 8; but as it is unsigned we need to reserve a bit. That's to say 2^3-1 = 7 for positive and 2^3 = 8 for negative. Let's see why:

See we cannot represent the 8 because it would be using the bit sign. Now let's see the negatives.

Notice that negative numbers have the sign bit on. And that's why they can represent on more decimal number. Notice that the value of MIN_VALUE in this case is formed with all bits set to 0, but the sign bit. That is why the MIN_VALUE in interger is 80000000 and the one that you said is -1, because it has all the bits set to 1, that's to say ffffffff.

Remember that you obtain a negative number by means of negating the bits of the positive one and then adding one.

[ May 15, 2005: Message edited by: Edwin Dalorzo ]

[ May 15, 2005: Message edited by: Edwin Dalorzo ]