(ABCD xor FFFF) + 1 = 5433
which in decimal is 21554.? Except for sign, that's what you got.
To expand on that, here are the binary equivalents.? Note that I'm not "converting" to binary?―?these are the actual values the computer uses, and that we express s ABCD and FFFF for our convenience.
? ? ? ? 1010 1011 1100 1101 (= ABCD)
XOR 1111? 1111? 1111? 1111? (= FFFF. XOR flips the bits)
? ? ? ? ?-----------------------------
? ? ? ? ?0101 0100 0011 0010
then add 1 to complete the 2's complement operation.
? ? ? ? ?0101 0100 0011 0011
To convert to decimal, work from one end to the other, summing the bit values.? I'll go right to left (from the least significant bit).
1 × 1 = 1
1 × 2 = 2
0 × 4 = 0
0 × 8 = 0
1 × 16 = 16
1 × 32 = 32
0 × 64 = 0
0 × 128= 0
0 × 256 = 0
0 × 512 = 0
1 × 1024 = 1024
0 × 2048 = 0
1 × 4096 = 4096
0 × 8192 = 0
1 × 16384 = 16384
0 × 32768 = 0
Adding the bit values gives the expected 21555.? (The original number therefore must be -21555.)
ABCD as a 16 bit number is already negative, because the highest bit is a 1.
Hello guys,
I am doing conversion from hexadecimal to negative decimal the question is
to convert hexadecimal number to binary and decimal 16-bits for each number and two's complement representation for negative numbers
the hexadecimal is ABCD: base 16
Now: what I did is converting each number of the hex to its binary equivalent
this way
A is 1010
B is 1011
C is 1100
D is 1101
so I guess this answers the first question which is converting hex to two's complement representation for negative binary, now when I try to flip this binary I got which is
1010 1011 1100 1101
to
0101 0100 0011 0011
now what I should do is get the decimal number doing the multiply thing from right to left
when I do this I do not get the right answer which supposed to be
-21555
instead what I get is