Page 29 - CodePilot V5.0 C7
P. 29
Step 5 Once all digits have been processed if there’s any carry left, write it at the leftmost
position.
Truth table for binary addition:
A B A + B Carry
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
Example 1: Add 1011 and 1101 Example 2: Add 10111 and 110001
1 1 1 1 Carry 1 1 1 1 1 Carry
1 0 1 1 1 0 1 1 1
+ 1 1 0 1 + 1 1 0 0 0 1
1 1 0 0 0 1 0 0 1 0 0 0
Therefore, 1011 + 1101 = 11000 Therefore, 10111 + 110001 = 1001000
BINARY SUBTRACTION
To subtract binary numbers, follow these steps:
Step 1 Align the binary numbers you want to subtract, one below the other.
Step 2 Subtract starting from the right:
• If the top digit is greater than or equal to the bottom digit, subtract as normal.
• If the top digit is smaller, borrow a ‘1’ from the next left bit.
Step 3 When you borrow in binary, change the 1 in the next left bit to 0 and add 2 (which is
10 in binary) to the current digit being subtracted.
Step 4 Continue subtracting from right to left, borrowing when necessary.
Truth table for binary subtraction:
A B A ‑ B Borrow
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0
Example 1: Subtracting 100101 from 111101 Example 2: Subtracting 111 from 1000
1 1 1 1 0 1 1 1 Borrow
– 1 0 0 1 0 1 0 10 10 10
1 0 0 0
0 1 1 0 0 0 – 1 1 1
0 0 0 1
Therefore, 111101 – 100101 = 011000
Therefore, 1000 – 111 = 0001
27
Number System

