Upload
juniper-hudson
View
212
Download
0
Embed Size (px)
Citation preview
BINARY 1
Number Systems• Base 10
• uses the numbers 0-9• Represents numbers as ones, tens, hundreds etc
Hundreds Tens Ones Solution
0 4 3 0+40+3= 43
5 9 4 500+90+4= 594
Number Systems• Base 2
• uses the numbers 0-1• Each column is a factor of two• To calculate a conversion we add together the things that are
included (1) and not the things that aren’t (0)
128 64
32
16
8 4 2 1 Solution
0 0 0 1 0 0 0 1
0 1 0 1 0 0 1 0
1 0 0 0 0 1 0 0
1 1 0 0 1 0 0 1
128 64 32 16 8 4 2 1 Solution
0 0 0 1 0 0 0 1 16 + 1 = 17
0 1 0 1 0 0 1 0 64 + 16 + 2 = 82
1 0 0 0 0 1 0 0 128 + 4 = 132
1 1 0 0 1 0 0 1 128 + 64 + 8 + 1 = 201
Binary to Decimal Conversion• Practise converting the following binary to decimal
128 64 32 16 8 4 2 1 Solution
0 0 1 0 1 1 0 0
0 1 0 1 1 0 0 0
1 0 1 0 0 0 1 1
1 1 0 0 0 0 1 1
1 1 1 1 1 0 0 0
0 1 1 1 0 0 0 1
0 1 0 1 0 1 0 1
0 1 1 0 0 1 1 0
1 1 1 1 1 1 1 1
Binary to Decimal Conversion• SOLUTIONS
128 64 32 16 8 4 2 1 Solution
0 0 1 0 1 1 0 0 32 + 8 + 4 = 44
0 1 0 1 1 0 0 0 64 + 16 + 8 = 88
1 0 1 0 0 0 1 1 128 + 32 + 2 + 1 = 163
1 1 0 0 0 0 1 1 128 + 64 +2 + 1 = 195
1 1 1 1 1 0 0 0 128 + 64 + 32 + 16 + 8 = 248
0 1 1 1 0 0 0 1 64 + 32 + 16 + 1 = 113
0 1 0 1 0 1 0 1 64 + 16 + 4 + 1 = 85
0 1 1 0 0 1 1 0 64 + 32 + 4 + 2 = 102
1 1 1 1 1 1 1 1 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255
Decimal to Binary Conversion• To convert the other way, we work from the highest number to the
lowest number asking if it fits in our decimal number• Convert 39
• Does 128 fit into 39? No 0• Does 64 fit into 39? No 0• Does 32 fit into 39? Yes 1
how many are left over? 39-32 = 7• Does 16 fit into 7? No 0• Does 8 fit into 7? No 0• Does 4 fit into 7? Yes 1
how many are left over? 7-4 = 3• Does 2 fit into 3? Yes 1
how many are left over? 3-2 = 1• Does 1 fit into 1? Yes 1
how many are left over? 1-1=0
• 39 is 00100111
Decimal to Binary Conversion• Using the method in the previous slide, convert the
following decimal solutions to binary
128 64 32 16 8 4 2 1 Solution
5
19
27
35
49
87
167
232
240
Decimal to Binary Conversion• SOLUTIONS
128 64 32 16 8 4 2 1 Solution
0 0 0 0 0 1 0 1 5
0 0 0 1 0 0 1 1 19
0 0 0 1 1 0 1 1 27
0 0 1 0 0 0 1 1 35
0 0 1 1 0 0 0 1 49
0 1 0 1 0 1 1 1 87
1 0 1 0 0 1 1 1 167
1 1 1 0 1 0 0 0 232
1 1 1 1 0 0 0 0 240
Fractional Numbers• If a decimal number has values after the decimal point we
can still convert using the same process
2 1 . .5
.25
.125 .0625 .03125
.015625 Solution
0 1 . 1 0 0 0 0 0
1 0 . 0 1 1 0 0 0
0 0 . 0 1 1 1 0 0
1 1 . 1 0 0 1 0 1
2 1 . .5 .25 .125 .0625 .03125 .015625 Solution
0 1 . 1 0 0 0 0 0 1 + 0.5 = 1.5
1 0 . 0 1 1 0 0 0 2 + 0.25 + 0.125 = 2.375
0 0 . 0 1 1 1 0 0 0.25 + 0.125 + 0.0625 = 0.4375
1 1 . 1 0 0 1 0 1 2 + 1 + 0.5 + 0.0625 + 0.015625 = 3.578125
Fractional Numbers• Sometimes we find numbers that we can’t easily fit into
the binary grid – for these we use another system• Division by 2
• We repeatedly divide a number by two to get the final solution
Fractional Numbers – Division by 2• Convert 0.4
• Multiply it by 2• Put the whole number in one
column• Put the remainder in the next
column• Carry your remainder to be the
starting number in the next row• Repeat these steps• There is no rule how many
times you should do this... But I accept 5 times
Number Multiplic-ation
Whole Number
Part number
0.4 x 2 = 0 .8
0.8 x 2 =
x 2 =
x 2 =
x 2 =
x 2 =
x 2 =
• The binary number in the ‘whole number’ column, from top to bottom, is your binary solution
Fractional Numbers – Division by 2
• Convert 0.3
Number Multiplic-ation
Whole Number
Part number
0.3 x 2 =
x 2 =
x 2 =
x 2 =
x 2 =
x 2 =
x 2 =
• Convert 0.24
Number Multiplic-ation
Whole Number
Part number
0.24 x 2 =
x 2 =
x 2 =
x 2 =
x 2 =
x 2 =
x 2 =
Characters using Binary• When we use 8 bit binary, each combination can be
converted into decimal.• Each decimal value has a character associated with it.• For example: A is 65
a is 97• Your ASCII character set has been provided as a separate
handout.
Characters using Binary• Convert the following:
Character Decimal
#
100
F
84
p
32
Characters using Binary• Solutions
Character Decimal
# 35
d 100
F 70
T 84
p 112
(space) 32
Worksheet• Test your new binary < -- > decimal conversion skills with
worksheet : Binary_1