DOC PREVIEW
IUPUI CSCI 23000 - Floating Point Representation

This preview shows page 1-2-3-4-5-6 out of 17 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 17 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Fractional NumbersSlide 3Fractional Numbers (cont.)Slide 5Slide 6Floating Point Number RepresentationNormalizing NumbersSlide 9Slide 10Slide 11Real Life Example: IEEE 754Slide 13Slide 14IEEE 754 ConverterSlide 16AcknowledgementsDale RobertsDepartment of Computer and Information Science,School of Science, IUPUICSCI 230Information Representation: Floating Point Representation Dale Roberts, LecturerDale Roberts, [email protected]@cs.iupui.eduDale RobertsFractional NumbersFractional NumbersExamplesExamples: : 456.78456.781010 = 4 x = 4 x 101022 + 5 x + 5 x 101011 + 6 x + 6 x 101000 + 7 x + 7 x 1010-1-1+8 x +8 x 1010-2-21011.111011.1122 = 1 x = 1 x 2233 + 0 x + 0 x 2222 + 1 x + 1 x 2211 + 1 x + 1 x 220 0 + 1 x + 1 x 22-1-1 + 1 x + 1 x 22-2-2= 8 + 0 + 2 + 1 + 1/2 + ¼= 8 + 0 + 2 + 1 + 1/2 + ¼= 11 + 0.5 + 0.25 = 11.75= 11 + 0.5 + 0.25 = 11.751010Conversion from binary number system to Conversion from binary number system to decimal systemdecimal systemExamplesExamples: : 111.11111.1122 = 1 x = 1 x 2222 + 1 x + 1 x 2211 + 1 x + 1 x 220 0 + 1 x + 1 x 22-1-1 + 1 x + 1 x 22-2-2= 4 + 2 + 1 + 1/2 + ¼ = 7.75= 4 + 2 + 1 + 1/2 + ¼ = 7.751010ExamplesExamples: 11.011: 11.01122 22 21 20 2-1 2-2 2-34 2 1 ½ ¼ 1/8 2 1 0 -1 -2 -3 x x x xDale RobertsConversion from decimal number system to binary systemConversion from decimal number system to binary systemExamplesExamples: : 7.757.751010 = (?) = (?)221.1.Conversion of the Conversion of the integerinteger part: same as before – repeated division by 2 part: same as before – repeated division by 27 / 2 = 3 (Q), 7 / 2 = 3 (Q), 11 (R) (R)  3 / 2 = 1 (Q), 3 / 2 = 1 (Q), 11 (R) (R)  1 / 2 = 0 (Q), 1 / 2 = 0 (Q), 11 (R) 7 (R) 710 10 == 111 111222.2.Conversion of the Conversion of the fractional fractional part: perform a repeated multiplication by 2 and extract the integer part of part: perform a repeated multiplication by 2 and extract the integer part of the resultthe result0.75 x 2 =0.75 x 2 =11..50 50  extract extract 110.5 x 2 = 0.5 x 2 = 11..0 0  extract extract 11 0.75 0.751010 = 0. = 0.1111220.0 0.0  stop stop  Combine the results from integer and fractional part, 7.75Combine the results from integer and fractional part, 7.751010 = = 111111..111122How about choose some ofHow about choose some ofExamplesExamples: try 5.625: try 5.625BBwrite in the same order4 2 11/2 1/4 1/8=0.5=0.25 =0.125Dale RobertsFractional Numbers Fractional Numbers (cont.)(cont.)Exercise 1Exercise 1: Convert (0.625): Convert (0.625)10 10 to its binary formto its binary form Exercise 2Exercise 2: Convert (0.6): Convert (0.6)1010 to its binary formto its binary formSolution: Solution: Solution: 0.625 x 2 = 1.25  extract 10.25 x 2 = 0.5  extract 00.5 x 2 = 1.0  extract 1 0.0  stop (0.625)10 = (0.101)20.6 x 2 = 1.2  extract 10.2 x 2 = 0.4  extract 00.4 x 2 = 0.8  extract 0 0.8 x 2 = 1.6  extract 1 0.6 x 2 =   (0.6)10 = (0.1001 1001 1001 …)2Dale RobertsFractional Numbers Fractional Numbers (cont.)(cont.)Exercise 3Exercise 3: Convert (0.8125): Convert (0.8125)10 10 to its binary formto its binary formSolution: 0.8125 x 2 = 1.625  extract 1 0.625 x 2 = 1.25  extract 10.25 x 2 = 0.5  extract 00.5 x 2 = 1.0  extract 1 0.0  stop (0.8125)10 = (0.1101)2Dale RobertsFractional Numbers Fractional Numbers (cont.)(cont.)ErrorsErrorsOne source of error in the computations is due to back and One source of error in the computations is due to back and forth conversions between decimal and binary formatsforth conversions between decimal and binary formatsExample: (0.6)Example: (0.6)1010 + (0.6) + (0.6)10 10 = 1.2= 1.21010Since Since (0.6)(0.6)1010 = (0.1001 1001 1001 …)= (0.1001 1001 1001 …)22Lets assume a 8-bit representation: Lets assume a 8-bit representation: (0.6)(0.6)1010 = (0 .= (0 .10011001 10011001))2 2 , therefore, therefore0.60.60.100110010.10011001+ 0.6 + 0.6  + +0.100110010.100110011.001100101.00110010Lets reconvert to decimal system: Lets reconvert to decimal system: (1.00110010)(1.00110010)bb= 1 x = 1 x 220 0 + 0 x + 0 x 22-1-1 + 0 x + 0 x 22-2 -2 + 1 x + 1 x 22-3-3 + 1 x + 1 x 22-4 -4 + 0 x + 0 x 22-5-5 + 0 x + 0 x 22-6-6 + 1 x + 1 x 22-7-7 + 0 x + 0 x 22-8 -8 = 1 + 1/8 + 1/16 + 1/128 = 1.1953125= 1 + 1/8 + 1/16 + 1/128 = 1.1953125 Error = 1.2 – 1.1953125Error = 1.2 – 1.1953125 = 0.0046875= 0.0046875Dale RobertsIf x is a real number then its normal form representation is:x = f • Base Ewhere f : mantissaE: exponentexponentExample: 125.3210 = 0.12532 • 103 mantissa - 125.3210 = - 0.12532 • 103 0.054610 = 0.546 • 10 –1The mantissa is normalized, so the digit after the fractional point is non-zero. Note that in binary, the leading digit is always 1, so it is normally hidden.If needed the mantissa should be shifted appropriately to make the first digit (after the fractional point) to be non-zero & the exponent is properly adjusted.Floating Point Number RepresentationFloating Point Number RepresentationDale RobertsNormalizing NumbersNormalizing NumbersExample:134.1510 = 0.13415 x 1030.002110 = 0.21 x 10-2101.11B = .1011 x 23 or 1.011 x 22 (hidden1)0.011B = .11 x 2-1 or 1.1 x 2-2 (hidden1)AB.CDH= .ABCD x 162 0.00ACH= .AC x 16-2 Note that the concept of a hidden 1 only applied to binary.Dale RobertsFloating Point Number RepresentationFloating Point Number RepresentationAssume we use 16-bit binary pattern for normalized binary form based on the following convention (MSB to LSB)Sign of mantissa (±)= left most bit (where 0: +; 1: - )Mantissa (f)= next 11 bits, leading 1 is assumed, m=1.fExponent (E) = next 4 bits, bias 7 20=7 (0111). 21=8 (1000), 2-1=6 (0110)x = ± f • Base ELSBMSBExcess-7E : converted to binary, b1b2b3b4f = 1.?1?2?3?4…?11 ?12…?15+ : 0- : 1?1?2?3?4?11?10?9?8?7?5?6b2b3b4b1Dale RobertsQuestion:Question:How the computer expresses the 16-bit approximation of 1110.111010111111 in normalized binary form using the following conventionSign of mantissa = left most bit (where 0: +; 1: - )Mantissa = next 11 bits, leading 1 is hidden, really represents 12


View Full Document

IUPUI CSCI 23000 - Floating Point Representation

Download Floating Point Representation
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Floating Point Representation and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Floating Point Representation 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?