
Site Search
SECTION I-11: Addition and Subtraction of Hex Numbers
By studying issues related to software and hardware of computers, it is often necessary to add or subtract hex numbers. Hex addition and subtraction is explained and demonstrated below.
Addition of Hex Numbers:
Starting with the least significant digits, the digits are added together. If the result is less than 16, write that digit as the sum for that position. If it is greater than 16, subtract 16 from it to get the digit and carry 1 to the next digit. This is shown in example below.
Perform Hex Addition : 23D9 + 94BE | |||
---|---|---|---|
23D9 | D = 1410 | LSD: 9 + 14 = 23 | 23 - 16 = 7 with a carry |
+ 94BE | E = 1310, B = 1110 | 1 + 13 + 11 = 25 | 25 - 16 = 9 with a carry |
B897 | 1 + 3 + 4 = 8 | ||
B = 1110 | MSD: 2 + 9 = B |
Subtraction of Hex Numbers:
In subtracting two Hex numbers, if the second digit is greater than the first, borrow 16 from the preceding digit. This is demonstrated in example below.
Perform Hex Subtraction: 59F - 2B8 | ||
---|---|---|
59F | F = 1510 | LSD: 15 - 8 = 7 |
- 2B8 | B = 1110 | (9+16=25) , 25 - 11 = 14 (E) |
2E7 | E = 1410 | (5 - 1 = 4) , 4 - 2 = 2 |