Download presentation
Presentation is loading. Please wait.
1
Binary Math CS208
2
Decimal Addition Example 3 7 5 8 + 4 6 5 7 1) Add 8 + 7 = 15 Write down 5, carry 1 1 8 11 415 4) Add 3 + 4 + 1 = 8 Write down 8 3) Add 7 + 6 + 1 = 14 Write down 4, carry 1 2) Add 5 + 5 + 1 = 11 Write down 1, carry 1 Add 3758 to 4657:
3
Decimal Addition Explanation 1 1 1 3 7 5 8 + 4 6 5 7 8 4 1 5 What just happened? 1 1 1 (carry) 3 7 5 8 + 4 6 5 7 8 14 11 15 (sum) - 10 10 10 (subtract the base) 8 4 1 5 So when the sum of a column is equal to or greater than the base, we subtract the base from the sum, record the difference, and carry one to the next column to the left.
4
Binary Addition Rules Rules: 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1(just like in decimal) 1 + 1= 2 10 = 10 2 = 0 with 1 to carry 1 + 1 + 1= 3 10 = 11 2 = 1 with 1 to carry
5
Binary Addition Example 1 1 1 0 1 1 1 + 0 1 1 1 0 0 1 1 111 010011 Example 1: Add binary 110111 to 11100 Col 1) Add 1 + 0 = 1 Write 1 Col 2) Add 1 + 0 = 1 Write 1 Col 3) Add 1 + 1 = 2 (10 in binary) Write 0, carry 1 Col 4) Add 1+ 0 + 1 = 2 Write 0, carry 1 Col 6) Add 1 + 1 + 0 = 2 Write 0, carry 1 Col 5) Add 1 + 1 + 1 = 3 (11 in binary) Write 1, carry 1 Col 7) Bring down the carried 1 Write 1
6
Binary Addition Explanation 1 1 0 1 1 1 + 0 1 1 1 0 0 -. 1 1 111 010011 In the first two columns, there were no carries. In column 3, we add 1 + 1 = 2 Since 2 is equal to the base, subtract the base from the sum and carry 1. In column 4, we also subtract the base from the sum and carry 1. In column 6, we also subtract the base from the sum and carry 1. In column 5, we also subtract the base from the sum and carry 1. In column 7, we just bring down the carried 1 2 2223 222 What is actually happened when we carried in binary?
7
Binary Addition Verification Verification 110111 2 55 10 +011100 2 + 28 10 83 10 64 32 16 8 4 2 1 1 0 1 0 0 1 1 = 64 + 16 + 2 +1 = 83 10 1 1 0 1 1 1 + 0 1 1 1 0 0 1010011 You can always check your answer by converting the figures to decimal, doing the addition, and comparing the answers.
8
Binary Addition Example 2 Verification 111010 2 58 10 +001111 2 + 15 10 73 10 64 32 16 8 4 2 1 1 0 0 1 0 0 1 = 64 + 8 +1 = 73 10 1 1 1 0 1 0 + 0 0 1 1 1 1 1 1 11 001010 Example 2: Add 1111 to 111010. 11
9
Try It Yourself – Binary Addition 1 1 1 1 0 1 2 + 0 0 1 1 0 1 2 1 0 0 1 0 1 1 1 2 + 1 1 0 1 0 1 0 1 2 (Answers on next slide) Complete the following binary addition exercises:
10
Answers 1 1 1 1 0 1 2 61 10 + 0 0 1 1 0 1 2 +13 10 1 0 0 1 0 1 0 2 74 10 1 1 1 1 1 1 0 0 1 0 1 1 1 2 151 10 + 1 1 0 1 0 1 0 1 2 +213 10 1 0 1 1 0 1 1 0 0 364 10 1 1 1 1 1
11
Decimal Subtraction Example 8 0 2 5 - 4 6 5 7 Subtract 4657 from 8025: 791 1 11 8633 1)Try to subtract 5 – 7 can’t. Must borrow 10 from next column. 4) Subtract 7 – 4 = 3 3) Subtract 9 – 6 = 3 2)Try to subtract 1 – 5 can’t. Must borrow 10 from next column. But next column is 0, so must go to column after next to borrow. Add the borrowed 10 to the original 0. Now you can borrow 10 from this column. Add the borrowed 10 to the original 5. Then subtract 15 – 7 = 8. Add the borrowed 10 to the original 1.. Then subract 11 – 5 = 6
12
Decimal Subtraction Explanation So when you cannot subtract, you borrow from the column to the left. The amount borrowed is 1 base unit, which in decimal is 10. The 10 is added to the original column value, so you will be able to subtract. 8633 8 0 2 5 - 4 6 5 7
13
Binary Subtraction Explanation In binary, the base unit is 2 So when you cannot subtract, you borrow from the column to the left. The amount borrowed is 2. The 2 is added to the original column value, so you will be able to subtract.
14
Binary Subtraction Example 1 1 1 0 0 1 1 - 1 1 1 0 0 Example 1: Subtract binary 11100 from 110011 2 002 1 2 1101 Col 1) Subtract 1 – 0 = 1 Col 5) Try to subtract 0 – 1 can’t. Must borrow from next column. Col 4) Subtract 1 – 1 = 0 Col 3) Try to subtract 0 – 1 can’t. Must borrow 2 from next column. But next column is 0, so must go to column after next to borrow. Add the borrowed 2 to the 0 on the right. Now you can borrow from this column (leaving 1 remaining). Col 2) Subtract 1 – 0 = 1 Add the borrowed 2 to the original 0. Then subtract 2 – 1 = 1 1 Add the borrowed 2 to the remaining 0. Then subtract 2 – 1 = 1 Col 6) Remaining leading 0 can be ignored.
15
Binary Subtraction Verification Verification 110011 2 51 10 - 11100 2 - 28 10 23 10 64 32 16 8 4 2 1 1 0 1 1 1 = 16 + 4 + 2 + 1 = 23 10 1 1 0 0 1 1 - 1 1 1 0 0 2 002 1 2 11011 Subtract binary 11100 from 110011:
16
Binary Subtraction Example 2 1 0 1 0 0 1 - 1 0 1 0 0 Example 2: Subtract binary 10100 from 101001 2002 11010 Verification 101001 2 41 10 - 10100 2 - 20 10 21 10 64 32 16 8 4 2 1 1 0 1 0 1 = 16 + 4 + 1 = 21 10
17
Try It Yourself – Binary Subtraction (Answers on next slide) Complete the following binary subtraction exercises: 1 1 0 1 0 1 2 - 1 0 1 0 1 1 2 1 0 0 1 1 0 1 2 - 1 1 0 1 1 1 2
18
Answers 1 1 0 1 0 1 2 53 10 - 1 0 1 0 1 1 2 - 43 10 0 0 1 0 1 0 2 10 10 2020 1 0 0 1 1 0 1 2 77 10 - 1 1 0 1 1 1 2 - 55 10 0 1 0 1 1 0 2 22 10 20 2 0 02 1 2
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.