2’s Complement Hexadecimal Addition

In summary, The solution (green arrow) states that for example : 0xD + 0x9 = 0x16, which can also be written as 13 + 9 = 22. The 0x prefix is important in hexadecimal notation, and 0x16 is equivalent to 22 in decimal notation.
  • #1
siid14
1
0
TL;DR Summary
Working on 2's Complement Hexadecimal but still don't get the addition. I was looking at the post here: https://stackoverflow.com/questions/33322671/how-to-add-hex-numbers-using-twos-complement
The solution (green arrow) states that for example :

0xD + 0x9 = 0x16

Details :

0xD = 13,
0x9 = 9,
13 + 9 = 22,
22 = 0x16

Where does the 0x16 come from? I do get to add D + 9 = 13 + 19 = 22 so how come 22 is equal to 16 (assuming D + 9 = 16 is correct) How am I suppose this solution?
 
Technology news on Phys.org
  • #2
siid14 said:
Where does the 0x16 come from? I do get to add D + 9 = 13 + 19 = 22 so how come 22 is equal to 16 (assuming D + 9 = 16 is correct) How am I suppose this solution?
D + 9 is not meaningful, and 22 is obviously not equal to 16. The 0x prefix is vital.

We can write 0xD + 0x9 = 0x16 in hexadecimal, or we can write 13 + 9 = 22 in decimal, or we can even write 0xD + 0x9 ≡ 22 (note the use of the ≡ sign here to show equivalence as opposed to equality).

Note that 0x10 ≡ 16, so 0x16 = 0x10 + 0x6 ≡ 16 + 6 = 22.
 
Last edited by a moderator:

Similar threads

  • Programming and Computer Science
Replies
9
Views
1K
  • Sticky
  • Programming and Computer Science
Replies
13
Views
4K
  • Programming and Computer Science
Replies
29
Views
3K
  • Programming and Computer Science
Replies
5
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
  • Nuclear Engineering
Replies
1
Views
3K
Replies
3
Views
814
Replies
14
Views
959
  • Programming and Computer Science
2
Replies
60
Views
16K
Back
Top