Representing Real Numbers Using Floating Point Notation Lecture 6 CSCI 1405, CSCI 1301 Introduction to Computer Science Fall 2009
Real numbers in Binary System Remember that: ( ) 2 = 1* * * * * *2 -3 = = ( ) 2 (which is )= * 2 5.
Single Precision Floating Point Single precision floating point unit is a packet of 32 bits Divided into three sections one bit, eight bits, and twenty- three bits, in that order. Mantissa 23 bits Exponent 8 bits Sign 1 bit
Single Precision Floating Point Sign Field: one bit long, and is the sign bit. It is either 0 or 1; 0 indicates that the number is positive, 1 negative. The number * 2 5 is positive, so this field would have a value of 0. Exponent eight bits long, and serves as the "exponent" of the number, this "exponent" is actually 127 greater than the "real" exponent, in our x 2 5 number, the eight-bit exponent field would have a decimal value of = 132. In binary this is (Note: actual range of real exponent values from -126 to +128). Mantissa Field: twenty-three bits long, and serves as the "mantissa." In our * 2 5 number, the mantissa, the most significant 1 is assumed to be there and is left out to give us just that much more precision. Thus, our mantissa for our number would in fact be
Conversion from Decimal to Floating Point Representation ( ) 10 = (?) 2 (329) 10 =( ) 2 ( ) 10 = ( ) 2 0= * = * = 1.125* = 0.25* = 0.5* = 1*
Conversion from Decimal to Floating Point Representation ( ) 10 = ( ) 2 = * 2 8 The sign is positive, so the sign field is 0. The exponent is = 135, so the exponent field is The mantissa is merely (remember the implied 1 of the mantissa means we don't include the leading 1) plus however many 0s we have to add to the right side to make that binary number 23 bits long.
Thank You