Presentation is loading. Please wait.

Presentation is loading. Please wait.

Learning Objectives 3.3.1f - Describe the nature and uses of floating point form 3.3.1h - Convert a real number to floating point form Learn how to normalise.

Similar presentations


Presentation on theme: "Learning Objectives 3.3.1f - Describe the nature and uses of floating point form 3.3.1h - Convert a real number to floating point form Learn how to normalise."— Presentation transcript:

1 Learning Objectives 3.3.1f - Describe the nature and uses of floating point form 3.3.1h - Convert a real number to floating point form Learn how to normalise a floating point binary numbers Learn why we want to normalise floating point

2 Floating Point Denary 1.637 x 105 Recall Mantissa and Exponent
Start with 1.637 Shift point 5 places to the right. What base will we use for binary?

3 Shift point 5 places to the right.
Floating Point Binary Recall Mantissa and Exponent x 25 Start with Shift point 5 places to the right.

4 Converting Binary Floating Point to Decimal
20 and 7/8

5 Floating Point Representation
2’s complement is used for negatives Recall Mantissa and Exponent 1 Markout Exponent, Mantissa, and Decimal Sign Bit is Positive on exponent and mantissa Convert Exponent Positive exponent means shift decimal in mantissa +4 right Convert to decimal Positive Numbers +4 /8 = d

6 Negative Exponent 1 • 2’s complement is used
Markout Exponent, Mantissa, and Decimal Sign Bit is Negative on exponent and mantissa means 2’s complement numbers Convert Exponent From 2’s Complement But Remember It’s Negative Convert Mantissa From 2’s Complement But Remember It’s Negative Shift decimal -4 places means left Convert to decimal, Remember it’s negative Negative Numbers = -4 -1/64 + 1/ /512 =

7 1100111000001000 (6-bit exp) Mark Out Determine Signs
| Determine Signs Exponent is positive; Mantissa is negative Convert Exp to decimal; Remember sign Convert 2s complement +8 If mantissa is negative, convert it; Remember sign Convert 2s complement  Shift mantissa Convert mantissa; Remember sign  -100

8 Your Turn 8-bit mantissa, 4-bit exponent 2s complement, Normalised 0.125 -14.5

9 Normalisation Move That Decimal

10 Big Problem Normalisation is the way around this. 0.100000000 000010
x 22 2 x 23 2 x 24 2 If we let any number of leading 0s in and adjust the exponent we get multiple ways to represent the same number.  If we have more than 1 way to represent a number it reduces the "pool" of possible numbers we can represent. Normalisation is the way around this.

11 Another Big Problem Normalisation is the way around this.
x 22 2 Let’s add in some number of leading 0s and adjust the exponent.   We also have to drop the 101 off the end because we don't have enough bits to store it.    We've reduced the precision of our number. Normalisation is the way around this.

12 Normalisation Ensures only 1 way to represent each number
Ensures maximum range available Normalised numbers always begin with two bits that are different You may have to move the decimal yourself and adjust the exponent accordingly. Positive Numbers 0.1 Negative Numbers 1.0

13 Normalised Good (Normalised) Bad (Unnormalised) 0.100110011 110001
Bad (Unnormalised) 10 bit mantissa, 6 bit exponent Normalised begin with different patterns Remember, may need to change your exponent to make it normalised

14 Your Turn Exponent is negative, convert it back to decimal = 25 (negative) Move decimal to normalised location To get back to original location, I have to move decimal -2 places = -27 is the new exponent  2s comp Float =

15 Your Turn Exponent is positive, convert it back to decimal = 19 (positive) Move decimal to normalised location To get back to original location, I have to move decimal -2 places = 17 is the new decimal 100010 Float =

16 Converting Fractions to Binary

17 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

18 .011110 Fill in with following 0s to number of bits you need
Example 15/32 = .01111 Multiply Result Binary x 2 x 2 1.8750 1 .8750 x 2 1.75 .75 x 2 1.5 .5 x 2 1.0 Fill in with following 0s to number of bits you need

19 Converting Decimal to Binary Floating Point (The Whole Thing Together)

20 Given a Decimal Number BinInteger = Convert integer part of number to binary BinFraction = Convert fractional part of number to binary If decimal number is negative BinInteger = 2s complement of BinInteger BinFraction = 2s complement of BinFraction NonNormalFloat = write BinInteger + “.” + BinFraction NormalFloat = Normalise NonNormalFloat Exponent = Count decimal movement & determine sign Convert Exponent to binary If Exponent is negative Exponent = 2s complement of Exponent If NormalFloat has empty slots Fill with 0s on right If Exponent has empty slots Fill with 0s if positive or 1s if negative on left Answer = NormalFloat join Exponent

21 Full Example: -27.625 10-bit Mantissa 6-bit Exponent 0000011011
BinInteger = Convert integer part of number to binary BinFraction = Convert fractional part of number to binary If decimal number is negative BinInteger = 2s complement of BinInteger BinFraction = 2s complement of BinFraction NonNormalFloat = write BinInteger + “.” + BinFraction NormalFloat = Normalise NonNormalFloat Exponent = Count decimal movement & determine sign Convert Exponent to binary If Exponent is negative Exponent = 2s complement of Exponent If NormalFloat has empty slots Fill with 0s on right If Exponent has empty slots Fill with 0s if positive or 1s if negative on left Answer = NormalFloat join Exponent .101 Yes .011 +5 101 101000

22 Homework Assume 6-bit exponent, 10-bit mantissa, 2s complement, normalised form Convert to decimal

23 Homework Assume 10-bit mantissa, 6-bit exponent, 2s complement.
Convert to normalised floating point 123 0.1875 -15/32


Download ppt "Learning Objectives 3.3.1f - Describe the nature and uses of floating point form 3.3.1h - Convert a real number to floating point form Learn how to normalise."

Similar presentations


Ads by Google