Download Arithmetic in Base 2

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Location arithmetic wikipedia , lookup

Arithmetic wikipedia , lookup

Positional notation wikipedia , lookup

Transcript
EMMA HS 1 Outline
Week #4
Review Homework - Numbering Systems Used By Computers
Arithmetic in Base 2
Base 2 (Revisited)
Base 10 Place Values
Base 2 Place Values
Binary/Decimal Conversion Examples
Adding in Base 2
Homework –
Arithmetic in Base Two
Problems (DO THESE PROBLEMS AS ONLINE QUIZ)
base 2 conversion problems
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
What is the base 10 value of 1100100 (base 2)?
What is the base 2 value of 107 (base 10)?
What base 10 number does 101001 (base 2) represent?
What base 10 number does 11111 (base 2) represent?
Write 74 (base 10) using base 2 numerals.
What base 10 number does 10111 (base 2) represent?
Write 96 (base 10) using base 2 numerals.
Convert 111110 (base 2) to base 10.
Convert 1000101 (base 2) to base 10.
Convert 10001 (base 2) to base 10.
base 2 addition problems (all numbers are base 2)
1.
2.
3.
4.
5.
6.
1101 + 1011
1111 + 100001
101101 + 100011
11000 + 10000
1001 + 1111 + 1001 + 1000
1110 + 111101
Arithmetic in Base 2
Base 2 The system of numbers that we normally use is the Hindu-Arabic system. This system is a base 10
system and uses the ten digits
0, 1, 2, 3, 4, 5, 6, 7, 8, and 9
Whole numbers in this system have values equal to the sums of the products of the digits and their place values.
The place values in this system are as shown here:
…
10,000
Base 10 Place Values
1,000
100
10
1
Thus, the number 2001 has the value of
…
10,000
1,000
100
10
2
0
0
2 times 1000, plus 0 times 100, plus 0 times 10, plus 1 times 1
1
1
And the number 4327 has the value of
…
10,000
1,000
100
10
4
3
2
4 times 1000, plus 3 times 100, plus 2 times 10, plus 7 times 1
1
7
Not all systems use ten digits. Some systems use fewer than ten digits, and some use more than ten digits. Each
system uses the same number of digits as the base of the system. The base 9 system uses nine digits, the base 6
system uses six digits, the base 4 system uses four digits, etc. Any whole number greater than 1 can be used as a
base of a number system.
In this lesson, we will investigate the base 2 number system, which uses the two digits 0 and 1. Another name
for this system is the binary number system. The place values in the base 2 system are shown here as base 10
numbers.
Base 2 Place Values
…
128
64
32
16
8
4
2
1
The first place to the left of the decimal point has a value of 1. To get the next value, we multiply 1 by 2 and get
2. To get the next value, we multiply 2 by 2 and get 4. To get the next value, we multiply 4 by 2 and get 8, etc.
Each place has a value that is twice the value of the place to its right.
Example 1
What is the base 10 value of 10101 (base 2)?
Solution We begin by making a table of base 2 place values. We use base 10 numerals to write
the place values. Then we write the digits of the base 2 numeral under their place values.
Base 2 Place Values
…
128
64
32
16
8
4
1
0
1
We see that we have one 16, no 8’s, one 4, no 2’s, and one 1.
16 + 4 + 1 = 21.
2
0
1
1
Since the sum of these numbers is 21, the base 10 value of 10101 (base 2) is 21 (base 10).
10101 (base 2) equals 21 (base 10)
Example 2
What base 10 number does 110101 (base 2) represent?
Solution We make a table of place values and write each digit of the base 2 numeral beneath its
proper place.
Base 2 Place Values
…
128
64
32
16
8
4
2
1
1
0
1
0
We see that we have one 32, one 16, no 8’s, one 4, no 2’s, and one 1.
32 + 16 + 4 + 1 = 53
1
1
110101 (base 2) equals 53 (base 10)
Example 3
Write 102 (base 10), using base 2 numerals
Solution We always begin by writing a table of place values.
…
128
64
1
102
- 64
38
Base 2 Place Values
32
16
8
1
0
0
38
- 32
6
4
2
1
1
6
-4
2
2
-2
0
1
0
Thus, we see that we can write 102 (base 10) as 1100110 (base 2).
Example 4
Write 43 (base 10), using base 2 numerals
Solution There are no 64’s in 43, but there is one 32 in 43. So we put a 1 under the thirty-two’s place
and subtract 32 from 43 to get 11.
43 – 32 = 11
There are no 16’s in 11, so we put a 0 under the sixteen’s place and subtract 0 from 11.
11 – 0 = 11
Since there is one 8 in 11, we put a 1 under the eights’ place and subtract 8 from 11.
11 – 8 = 3
There are no 4’s in 3. Thus, we put a 0 under the fours’ place and subtract 0 from 3.
3–0=3
Since there is one 2 in 3, we put a 1 under the twos’ place and subtract 2 from 3.
3–2=1
There is a single 1 in 1, so we put a 1 under the units’ place.
…
128
64
Base 2 Place Values
32
16
8
1
0
1
4
0
2
1
1
1
The number 43 has one 32, one 8, one 2, and one 1, so 43 (base 10) = 101011 (base 2)
Adding in base 2
We review our procedure for adding in base 10 by noting that we split the sum of a
column into two parts. One part is a whole number times the base, and the other part is the remainder. We
record the remainder and carry the whole number to the next column.
2
539
844
+ 638
21
21 = 2(10) + 1
539
844
+ 638
1
In the problem above, the sum of the first column is 21. This is 2 times the base (10) with 1 left over. We record
the 1 and carry the 2 to the second column, as we see on the right-hand side above.
2
539
844
+ 638
12
1
12
12 = 1(10) + 2
539
844
+ 638
21
When we find the sum of the digits in the second column, we get 12. This is 1 times the base (10) with 2 left
over. We record the 2 and carry the 1 to the next column.
12
539
844
+ 638
20
21
212
20 = 2(10) + 0
539
844
+ 638
2021
The total of the third column is 20. This is 2 times the base, with 0 left over. We record the 0 and carry the 2.
The total in the fourth column is 2, which is 0 times the base (10) with 2 left over.
We will use the same procedure to add in base 2. We split the sum of a column into two parts. One part is a
whole number times the base, and the other part is the remainder. We record the remainder and carry the whole
number.
Example 5
Solution
Add: 1111 (base 2) + 1011 (base 2) + 1101 (base 2) + 1101 (base 2)
We record the numbers vertically and add the first column. We express the sum as a whole
number times the base, plus a remainder.
1111
1011
1101
+ 1101
4
4 = 2(2) + 0
The sum of the first column in base 10 is 4. This is 2 times the base (2), with a remainder of 0.
We record the 0 and carry 2 to the next column and add this column.
2
1111
1011
1101
+ 1101
4
0
4 = 2(2) + 0
This sum is 2 times the base, with a remainder of 0. We record 0 and carry 2. Then we add the
third column.
22
1111
1011
1101
+ 1101
5
00
5 = 2(2) + 1
We get 5, which is 2 times the base, with a remainder of 1. We record 1, carry the 2, and add
the next column.
3222
1111
1011
1101
+ 1101
3
0100
3 = 1(2) + 1
But 3 is 1 times the base, with a remainder of 1.
3222
1111
1011
1101
+ 1101
110100
= decimal
15
11
13
+ 13
52
So our final sum in base 2 is 110100.
As a check, we can convert everything to base 10 and compare the results. The addends are
15, 11, 13 and 13 in base 10. So 110100 (base 2) should equal 15 + 11 + 13 + 13 (base 10),
Which is 52. We use the place value chart to verify this.
…
128
64
32
1
16
1
8
0
4
1
2
0
1
0
We see that 110100 (base 2) equals 32 + 16 + 4 (base 10), which also equals 52. So our
addition was correct.