Question

Now, suppose you have the following two 8-bit hexadecimal numbers, both of which use two's complement:...

Now, suppose you have the following two 8-bit hexadecimal numbers, both of which use two's complement: ef 4a

4. What is the decimal equivalent of each of these numbers?

6. What is their sum in hexadecimal? (Note that the sum must also be confined to 8 bits in order for two's complement to work.)

0 0
Add a comment Improve this question Transcribed image text
Answer #1
4)
Hexadecimal     Binary
    0           0000
    1           0001
    2           0010
    3           0011
    4           0100
    5           0101
    6           0110
    7           0111
    8           1000
    9           1001
    A           1010
    B           1011
    C           1100
    D           1101
    E           1110
    F           1111
Use this table to convert from hexadecimal to binary
Converting EF to binary
E => 1110
F => 1111
So, in binary EF is 11101111
EF in binary is 11101111

Converting 4A to binary
4 => 0100
A => 1010
So, in binary 4A is 01001010
4A in binary is 01001010

first = 11101111
since left most bit is 1, this number is negative number.
so, follow these steps below to convert this into a decimal value.
I. first flip all the bits. Flip all 0's to 1 and all 1's to 0.
   11101111 is flipped to 00010000
II. Add 1 to above result
00010000 + 1 = 00010001
III. Now convert this result to decimal value
=> 10001
=> 1x2^4+0x2^3+0x2^2+0x2^1+1x2^0
=> 1x16+0x8+0x4+0x2+1x1
=> 16+0+0+0+1
=> 17
so, 11101111 in 2's complement decimal is -17

second = 01001010
since left most bit is 0, this number is positive
so, we can directly convert this into a decimal value
=> 1001010
=> 1x2^6+0x2^5+0x2^4+1x2^3+0x2^2+1x2^1+0x2^0
=> 1x64+0x32+0x16+1x8+0x4+1x2+0x1
=> 64+0+0+8+0+2+0
=> 74
so, 01001010 in 2's complement decimal is 74

Answer: numbers in decimal are -17 and 74

6)
Adding 11101111 and 01001010 in binary
    11101111
    01001010
-------------
 (1)00111001
-------------
Sum produces a carry of 1. We can ignore that carry.
So, sum of these numbers in binary is 00111001

Verification
---------------
sum = 00111001
since left most bit is 0, this number is positive
so, we can directly convert this into a decimal value
=> 111001
=> 1x2^5+1x2^4+1x2^3+0x2^2+0x2^1+1x2^0
=> 1x32+1x16+1x8+0x4+0x2+1x1
=> 32+16+8+0+0+1
=> 57
This is correct since we can verify that -17+74 = 57
So, there was no overflow.

Now, let's convert the sum 00111001 back to hexadecimal

Converting 00111001 to hexadecimal
0011 => 3
1001 => 9
So, in hexadecimal 00111001 is 0x39

Answer: 0x39
Add a comment
Know the answer?
Add Answer to:
Now, suppose you have the following two 8-bit hexadecimal numbers, both of which use two's complement:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT