binary airthmatics
binary airthmatics
binary airthmatics
View of Hardware
Binary Arithmetic
Binary Addition
The steps used for a computer to complete
addition are usually greater than a human, but
their processing speed is far superior.
RULES
0+0=0
0+1=1
1+0=1
1 + 1 = 0 (With 1 to carry)
1 + 1 + 1 = 1 (With 1 to carry)
Binary Addition
EXAMPLE
1 0 0 1 +
1 0 1 1
Binary Addition
EXAMPLE
1 0 01 1 +
1 0 1 1
0
Binary Addition
EXAMPLE
1 01 01 1 +
1 0 1 1
0 0
Binary Addition
EXAMPLE
1 01 01 1 +
1 0 1 1
1 0 0
Binary Addition
EXAMPLE
1
1 01 01 1 +
1 0 1 1
0 1 0 0
Binary Addition
EXAMPLE
1 01 01 1
1
+
1 0 1 1
10 1 0 0
Binary Addition
CHECK THE ANSWER
9 +
11
20
Activity 1
Perform the following additions in binary.
10110 + 4010 =
32010 + 1810 =
7610 + 27110 =
Binary Subtraction
Computers have trouble performing
subtractions so the following rule should be
employed:
“X – X is the same as
X + -X”
This is where two’s complement is used.
Binary Subtraction
RULES
2. Convert the number to binary.
8 = 00001000 2
00001000 2
11110111 2
Binary Subtraction
EXAMPLE 1
2. Perform two’s complement.
11110111 2
+
00000001 2
11111000 2
Try 6 - 10
10 10
Binary Subtraction
EXAMPLE 2
2. Convert to binary
6 = 000001102
10 = 00001010 2
000010102
111101012
Binary Subtraction
EXAMPLE 2
2. Perform two’s complement.
11110101 2
+
00000001 2
=11110110 2
Binary Subtraction
EXAMPLE 2
2. Add the two numbers together.
00000110 2
+
11110110 2
11111100 2
00000011 2
=00000100 2
Binary Subtraction
EXAMPLE 2
2. We then add the sign bit back.
00000100 2
=10000100 2
Activity 2
Perform the following subtractions.
3. 22 - 8 =
4. 76 - 11 =
5. 6 - 44 =
Binary Multiplication
Multiplication follows the general principal of
shift and add.
The rules include:
0*0=0
0*1=0
1*0=0
1*1=1
Binary Multiplication
EXAMPLE 1
Complete 15 * 5 in binary.
3. Convert to binary
15 = 00001111 2
5 = 00000101 2
1111
00000 Shift One Place
Binary Multiplication
EXAMPLE 1
2. Shift one place to the left and multiple the
third digit.
1111 2 1111 x 1 = 1111
x
101 2
1111
00000
111100 Shift One Place
Binary Multiplication
EXAMPLE 1
2. Add the total of all the steps.
1111
00000 +
111100
1001011
12 * 3 = 1 0 0 1 0 02
13 * 5 = 1 0 0 0 0 0 12
97 * 20 = 1 1 1 1 0 0 1 0 1 0 02
121 * 67 = 1 1 1 1 1 1 0 1 0 1 0 1 12
Binary Division
Division in binary is similar to long division in
decimal.
It uses what is called a shift and subtract
method.
Binary Division
EXAMPLE 1
Complete 575 / 25 using long division.
0 Take the first digit of 575 (5) and see if 25
will go into it.
2. 25 575
If it can not put a zero above and take the
next number.
02
How many times does 25 go into 57?
TWICE
2. 25 575
Binary Division
02 How much is left over?
2. 25 575 57 – (25 * 2) = 7
50
7
Drop down the next value
02
2. 25 575
50
75
Binary Division
023 Divide 75 by 25
2. 25 575 Result = 3
50
75
Check for remainder
023
75 – (3 * 25) = 0
2. 25 575 FINISH!
50
75
75
0
Binary Division
Complete the following:
25/5
101 11001
101 11001
101 11001
101 11001
101
101 11001
+ 011
001
Binary Division
Step 11: Determine if 1 0 1 will fit into the remainder
0 0 1. The answer is no so you must bring down the
next number.
0 0 1
101 11001
+ 011
0010
Binary Division
Step 12: 1 01 does not fit into 0 0 1 0. Therefore, a
zero is placed above the last bit. And the next number
is used.
0 0 1 0
101 11001
+ 011
00101
Binary Division
Step 13: 1 0 1 does fit into 1 0 1 so therefore, a one is
placed above the final number and the process of shift
and add must be continued.
0 0 1 0 1
101 11001
+ 011
00101
+
011
000
Binary Division
Step 14: The final answer is 1 0 1 (5) remainder zero.
Activity 4
Complete the following divisions:
340 / 20
580 / 17
Activity 5
40/4
36/7