Taking the binary of 0x80000000
we get
1000 0000 0000 0000 0000 0000 0000 0000
How does this equate to -2147483648
. I got this question with this program.
class a
{
public static void main(String[] args)
{
int a = 0x80000000;
System.out.printf("%x %d
",a,a);
}
}
meow@VikkyHacks:~/Arena/java$ java a
80000000 -2147483648
EDIT I learned that 2's complement is used to represent negative numbers. When I try to equate this with that 1's complement would be
1's Comp. :: 0111 1111 1111 1111 1111 1111 1111 1111
2's Comp. :: 1000 0000 0000 0000 0000 0000 0000 0000
which again does not make any sense, How does 0x80000000
equate to -2147483648
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…