add | to the result. Inverting the bits is simply a matter of changing all Os to 1s and
1s to 0s. This is called the / 5 complement. See Example 0-9.
Take the 2’s complement of 10011101.
Solution:
10011101 binary number
01100010 1’s complement
ap 1
01100011 2’s complement
Addition and subtraction of hex numbers
In studying issues related to software and hardware of computers, it is
often necessary to add or subtract hex numbers. Mastery of these techniques is
essential. Hex addition and subtraction are discussed separately below.
Addition of hex numbers
This section describes the process of adding 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. The best way to explain this is by
example, as shown in Example 0-10.
Example 0-10
Perform hex addition: 23D9 + 94BE.
Solution:
23D9 LSD: 9+ 14=23 23 — 16 =7 with a carry
+ 94BE 1413411 =25 25 — 16 = 9 with a carry
B897 14+3+4=8
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. See Example 0-11.
[Example 0-11
Perform hex subtraction: S9F — 2B8.
Solution:
LSD: 8 from 15=7
11 from 25 (9 + 16) = 14 (E)
2 from 4 (5-1) =2
CHAPTER 0: INTRODUCTION TO COMPUTING 7