Is it necessary to convert to binary when doing addition with a hexadecimal's two's complement?

84 Views Asked by At
3 9 6 F E 2 + 5 3 8 A A A

This is the problem that I have to solve assuming two's complement addition. I know how to find the two's complement of each.

C 6 9 0 1 E

A C 7 5 5 6 

However, most of the problems that I see online with examples of how to solve this only show how to solve the problem with binary numbers.

Is it necessary to convert it to binary, find the two's complement, solve the problem, and then convert it back to hexadecimal? Or can I just solve the problem like it is above?

If I just add the two's complements then I get

7 3 0 5 7 4 

with an overflow of one. However, that is incorrect.

The correct answer is apparently

8 C F A 8 C. 

Which I can see is just adding the two numbers together without converting them into two's complements. But then it apparently has an overflow when doing it like regular I did not get one.

Why? Is the problem that it needs to be converted to binary first or is that unnecessary and I am just solving the problem wrong?

1

There are 1 best solutions below

0
John Kugelman On

There are two things that are confusingly called "two's complement":

  1. Two's complement is an encoding, specifically of negative numbers.
  2. Two's complement is an operation where you flip all the bits and add 1.

"Two's complement addition" doesn't require the operation at all. It really just means doing addition with numbers encoded in two's complement. Well, that's just regular old addition, actually, so all you need to do is add the two numbers together. If that ends up overflowing into the leftmost bit then when you interpret the result you'll want to read it as a two's complement negative number.

All of this can be done in hex, as you have done. If the leftmost hex digit is 8-F then the result is negative.