0% found this document useful (0 votes)
2 views

8-Binary Arithmetic

Uploaded by

Sieele
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

8-Binary Arithmetic

Uploaded by

Sieele
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Binary Arithmetic

Addition, Subtraction and


Multiplication
Decimal Addition - Review
Step 1: Add the first (rightmost) column
Step 2: Record the units digit of the
column sum. If the sum exceeds 9, carry
the tens digit (1), to the next column.
Step 3: If there are additional columns or if
there is a carry from step 2, add the next
column and repeat step 2. Otherwise, stop.

MATH 1183 Computer Mathematics and Statistics


2
Decimal Addition Examples
Before: Step 1 → 3 + 1 = 4
Step 2 → Write 4
34 573
+ 52 861
Step 3 → 7+6 = 13
Step 2 → Write 3 and carry 1.
Step 3 → 1+5+8 = 14
After: Step 2 → Write 4 and carry 1.
1 1
34 573 Step 3 → 1+4+2 = 7
+ 52 861 Step 2 → Write 7
87 434 Step 3 → 3+5 = 8
Step 2 → Write 8
Step 3 → Stop
MATH 1183 Computer Mathematics and Statistics
3
Binary Addition
Good news!
The three-step
algorithm for addition of
decimal numbers is the
same for addition of
binary numbers.
Step 2: Replace 9 by 1
and tens by twos!

MATH 1183 Computer Mathematics and Statistics


4
Binary Addition Facts
0 + 0 = 0 → (you already know this!)
0 + 1 = 1 → (you already know this!)
1 + 0 = 1→ (you already know this!)

1 + 1 = 10, or 0 with a carry of 1


→ 01 + 01 = 2 or 10 (binary 2)
1 + 1 + 1 = 1, with a carry of 1
→ 01 + 01 + 01 = 3 or 11 (binary 3)
MATH 1183 Computer Mathematics and Statistics
5
Binary Addition Example

MATH 1183 Computer Mathematics and Statistics


6
Addition Examples
111 11011.01
+ 101 + 101.1101

1001 + 1101 + 110 + 1011 How will you


Add the first two and then check your
add the others one at a answers?
time to a running total

MATH 1183 Computer Mathematics and Statistics


7
Addition Solutions
11 11111 1
111 11011.01
+ 101 + 101.1101
1100 100001.0001
1001
+ 1101
1001 + 1101 + 110 + 1011 10110
Add the first two and then + 110
add the others one at a time
11100
to a running total
+ 1011
100111

MATH 1183 Computer Mathematics and Statistics


8
Decimal Subtraction - Review
Step 1 → if the lower digit is greater than
the upper digit, borrow from the next
column to the left. (The value borrowed is
equal to 10).
Special→ borrowing from 0. You borrow
from the first non-zero digit to the left, all
intervening 0s become 9.
Step 2 → Subtract the lower value from the
upper value.
MATH 1183 Computer Mathematics and Statistics
9
Decimal Subtraction Example
Before: Step 2 → 8-3=5 (3 < 8)
Step 1 → 6 is > 4
548
- 263
Need to borrow! 10 is added to
4 to become 14 and 1 is
subtracted from 5.
After: Step 2 → 14-6=8
4
548
/
1 Step 2 → 4-2=2
- 263
285
Easier → No borrowing from 0!

MATH 1183 Computer Mathematics and Statistics


10
Decimal Subtraction Example
Before: Step 1 → 5 is > 3
Need to borrow but 0 is there.
84 003
- 21 625
Special → first non-zero is 4,
make it 3 and change all 0s to
9.
After: Step 2 → 9-2=7
3 99
Step 2 → 9-6=3
84
/ 003
//
1

- 21 625 Step 2 → 3-1=2


62 378 Step 2 → 8-2=6
Special → borrowing from 0!

MATH 1183 Computer Mathematics and Statistics


11
Binary Subtraction
Good news!
The two-step algorithm
for subtraction of
decimal numbers is the
same for subtraction of
binary numbers.
Step 2: Replace 9 by 1
and tens by twos!

MATH 1183 Computer Mathematics and Statistics


12
Binary Subtraction Facts
0–0=0
1–0=1
1–1=0
0 – 1 = 1, with a borrow of 1 from the next
column

MATH 1183 Computer Mathematics and Statistics


13
Binary Subtraction Example

MATH 1183 Computer Mathematics and Statistics


14
Subtraction Examples
Before: Before:

1 1101 1 1000
- 1011 - 1 0011

After: After:
0 011
1 1101
/1 1 1000
/ //
1

- 1011 - 1 0011
1 0010 0 0101

MATH 1183 Computer Mathematics and Statistics


15
Decimal Multiplication -
Review
Recall that multiplying decimal numbers
can be reduced to multiplying numbers
by digits and then adding.
1234
* 263
3702

+ 74040
246800
324542

MATH 1183 Computer Mathematics and Statistics


16
Binary Multiplication
Multiplying a number by the bit 0 or 1 yields
respectively 0 or the number itself.

110 1011 110 1011

* 1 0110 * 1 0110
000 0000
1101 0110 1101 0110
1 1010 1100 1 1010 1100
10 1000 0010 00 0000 0000
110 1011 0000 110 1011 0000
1001 0011 0010

MATH 1183 Computer Mathematics and Statistics


17

You might also like