Professional Documents
Culture Documents
Lecture 04
Lecture 04
1
LEARNING OBJECTIVES
• Binary fractions
2
BINARY MULTIPLICATION
• Because we only have two digits in binary, learning all of the times
tables is pretty easy:
• 0×0=0
100
• 0×1=0 × 11
100
• 1×0=0
1000
• 1×1=1 1100
• We then multiply in the same way we do in decimal.
3
YOU DO - BINARY MULTIPLICATION
4
SHIFTS AND MULTIPLICATION
5
<< LEFT SHIFT, >> RIGHT SHIFT
• e.g if the number is 11012 and we apply << 310 it means move the
zeros and ones 3 places to the left: 11010002
• e.g. if the number is 11012 and we apply >> 210 it means move the
zeros and ones 2 places to the right (if we only have integers the
fractional parts are lost): 112 is the answer in this case, if we have
fractions as well the answer would be 11.012
6
DIVISION
• https://andybargh.com/binary-division/
7
BIGGER AND SMALLER
8
BINARY FRACTIONS
9
DECIMAL FRACTION TO BINARY
• e.g. 0.1875
ones or zeros Answer so far
. 1875
0 375
0 75
1 5
1 0
read answer this way: 0.00112
10
EXAMPLE
ones or zeros Answer so far
.24
12
FLOATING POINT
13
BIGGEST
• In this format the "binary" point is assumed to be to the left of the first significant digit of
the mantissa, so
0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1
• a lot bigger than -32768 to 32767 (but the gaps between numbers are bigger too)
• we can also get very small numbers (with the exponent being negative)
14
CONVERTING TO FLOATING POINT
• Then normalize (move the binary point to the left of the first 1).
• 710 = 1112
1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 In hex: F807
15
CONVERTING TO FLOATING POINT
• 20.7510 = 10100.112
• Then normalize (move the binary point to the left of the first 1).
• 10100.11 = .1010011 × 25
• 510 = 1012
0 1 0 1 0 0 1 1 0 0 0 0 0 1 0 1 In hex:5305
16
GOING THE OTHER WAY
• 0.112 × 24 = 11002
• which is 1210
17
GOING THE OTHER WAY
• -0.10000012 × 22 = -10.000012
• which is -2.03125
18
YOU DO
19
REVISION
• Convert -0.5 into the text book’s floating point format. Write the
answer in hexadecimal
1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1