Floating Point Numbers
Floating Point Numbers
1
Floating Point Denary
• Recall Mantissa and Exponent
1.637 x 105
163700.
0.10100111 x 25
10100.111
Converting Binary
Floating Point to Decimal
0 • 1 0 1 1 0 0 1 0 0 0 0 0 1 0 0
1. Markout Exponent, Mantissa, and Decimal 1. 0.101100100 000100
3. Convert Exponent 3. +4
Move
That
Decimal
.
1 0100111
Big Problem
0.100000000 000010 0.100000000 x 22 2
0.010000000 000011 0.010000000 x 23 2
0.001000000 000100 0.001000000 x 24 2
• Bad (Unnormalised)
– 0.001101001 100111
– 1.110001101 010011
Your Turn
• 0.001101001 100111
Exponent is negative, convert it back to decimal
011001 = 25 (negative)
Move decimal to normalised location
0.110100100
To get back to original location, I have to move decimal -2 places
-25 + -2 = -27 is the new exponent
011011 2s comp 100101
Float = 0.110100100 100101
Your Turn
• 1.110001101 010011
Exponent is positive, convert it back to decimal
010011 = 19 (positive)
Move decimal to normalised location
1.000110100
To get back to original location, I have to move decimal -2 places
19 + -2 = 17 is the new decimal
100010
Float = 1.000110100 100010
Converting Fractions
to Binary
Convert Fractions to Binary
• This is a simple algorithm for converting fractional parts of
numbers to binary
• Put the fraction into decimal format
• Multiply by 2
• If the whole number part of result is 0, then binary digit is 0; if
the whole number part of result is 1, then binary digit is 1
• Mod the result (take the fractional part only)
• Keep going until you get 0 as a result or fill all of your binary
digit slots
Example
• 15/32 = 0.46875 .01111
Multiply Result Binary
0.46875 x 2 0.93750 0
0.93750 x 2 1.8750 1
.8750 x 2 1.75 1
.75 x 2 1.5 1
.5 x 2 1.0 1
0000011011
BinInteger = Convert integer part of number to binary
BinFraction = Convert fractional part of number to .101
binary
If decimal number is negative Yes
BinInteger = 2s complement of BinInteger 1111100101
BinFraction = 2s complement of BinFraction .011
1111100101.011
NonNormalFloat = write BinInteger + “.” + BinFraction
NormalFloat = Normalise NonNormalFloat 1.00101011
Exponent = Count decimal movement & determine sign +5
Convert Exponent to binary 101
If Exponent is negative
Exponent = 2s complement of Exponent
If NormalFloat has empty slots Yes
Fill with 0s on right 1.001010110
If Exponent has empty slots Yes
101000
Fill with 0s if positive or 1s if negative on left
Answer = NormalFloat join Exponent 1001010110101000
Homework
• Assume 6-bit exponent, 10-bit mantissa, 2s
complement, normalised form
• Convert to decimal
1. 0101000000111111
2. 0001101000000110
3. 1101000000111111
4. 1001101000000110
Homework
• Assume 10-bit mantissa, 6-bit exponent, 2s
complement.
• Convert to normalised floating point
1. 123
2. 0.1875
3. -15/32