Adding Signed Hexadecimal numbers

Click For Summary
SUMMARY

The discussion centers on adding two signed hexadecimal numbers, A = 0D34 and B = DD17, represented in sign-magnitude format. The user initially converted the hexadecimal values to binary and attempted to use two's complement for the negative number, resulting in an incorrect sum of 301D. The correct approach involves recognizing that since B is negative and has a greater magnitude than A, the correct operation is to subtract the magnitude of A from B, yielding the correct result of CFE3.

PREREQUISITES
  • Understanding of signed hexadecimal numbers
  • Knowledge of binary representation and two's complement
  • Familiarity with sign-magnitude format
  • Basic arithmetic operations in binary
NEXT STEPS
  • Study the principles of sign-magnitude representation in hexadecimal
  • Learn about two's complement and its applications in signed number arithmetic
  • Practice converting hexadecimal numbers to binary and vice versa
  • Explore examples of signed addition and subtraction in different number systems
USEFUL FOR

Students studying computer science, software engineers dealing with low-level programming, and anyone interested in understanding hexadecimal arithmetic and signed number representations.

cjspringer
Messages
1
Reaction score
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
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:
Note that you got the two's complement of the required answer (CFE3) as you subtracted B from A , not A from B.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
13K
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 19 ·
Replies
19
Views
36K
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
10K