Adding Signed Hexadecimal numbers

In summary, the conversation discusses a homework assignment involving finding the sum of two hexadecimal numbers represented as signed 16-bit numbers in sign-magnitude format. The poster attempted to convert the numbers to binary and use the rules for signed addition, but obtained the incorrect answer. They later realized their mistake and found the correct answer to be CFE3.
  • #1
cjspringer
1
0
[Mentor's note: This post does not use the template because it was originally posted in a non-homework forum. I moved it here instead of deleting it and asking the poster to re-post, because he has already shown a reasonable amount of effort.]

I am having a bit of trouble with this homework assignment...

I am given two hexadecimal numbers.
A = 0D34
B = DD17

The directions are to find the sum of A and B if they represent signed 16-bit hexadecimal numbers stored in sign-magnitude format.

I attempted to convert both numbers to binary.

0D34 = 0000 1101 0011 0100
DD17 = 1101 1101 0001 0111

then, because the leading 1 in the binary representation of DD17 makes it negative, I took the 2's comp of DD17 and got 0010 0010 1110 1001.

However when I add that result with the binary representation of 0D34 I get..

0000 1101 0011 0100
+ 0010 0010 1110 1001
--------------------------------
0011 0000 0001 1101

which is represented in hexadecimal as 301D. I know this is wrong because the correct answer is CFE3.

Can anyone point out what I am doing wrong here? It would be of great help.
Thanks.
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
I believe the rules for signed addition are...

If they have the same sign, add the magnitudes and keep that sign.

If they have different signs, then subtract the smaller magnitude
from the larger one. The sign of the number with the larger
magnitude is the sign of the result.

It appears the second case applies because |B| > |A|.

Edit: Yes that gives the answer CFE3
 
Last edited:
  • #3
Note that you got the two's complement of the required answer (CFE3) as you subtracted B from A , not A from B.
 

FAQ: Adding Signed Hexadecimal numbers

What is a signed hexadecimal number?

A signed hexadecimal number is a number expressed in a base-16 numerical system with a sign (+ or -) to indicate its positive or negative value. It can range from -7FFFFFFF to 7FFFFFFF in decimal form.

How do you add two signed hexadecimal numbers?

To add two signed hexadecimal numbers, first convert them to their decimal equivalents. Then, add the decimal numbers together and convert the result back to a hexadecimal number. Remember to include the sign (+ or -) in the final answer.

Can you add a positive and a negative signed hexadecimal number?

Yes, you can add a positive and a negative signed hexadecimal number. The process is the same as adding two positive signed hexadecimal numbers, but the result may have a different sign depending on the values being added.

What happens if the result of adding two signed hexadecimal numbers is too large to be represented in signed hexadecimal form?

If the result of adding two signed hexadecimal numbers is too large to be represented in signed hexadecimal form, it is called an overflow. In this case, the result will need to be converted to a larger number format, such as double precision or floating-point, to accurately represent the value.

Are there any shortcuts or tricks for adding signed hexadecimal numbers?

Yes, there are some shortcuts and tricks for adding signed hexadecimal numbers. One method is to use the shortcut "9 + 1 = A" and "F + 1 = 10" when adding numbers in the same column. Additionally, breaking the numbers into smaller parts and adding them individually can make the process easier. It is important to double-check the final answer to ensure accuracy.

Similar threads

Back
Top