1 COMS 161 Introduction to Computing Title: Numeric Processing Date: November 08, 2004 Lecture Number: 30
2 Announcements
3 Review Real numbers –Representation –Limitations
4 Outline Real numbers –Representation –Limitations
5 IEEE Standard 754 Provides two floating point types –Single 24-bits of significand precision –Double 53-bits of significand precision
6 Single Precision IEEE standard 754 –Floating point number representation –32-bit s eeeeeeee fffffff ffffffffffffffff –s: (1) sign bit 0 means positive, 1 means negative sexponentsignificand
7 Single Precision s eeeeeeee fffffff ffffffffffffffff –e: (8) exponent bits [-126 … 127] A bias of 127 is added to the exponent –f: (24) fractional part [23 bits + 1 implied bit] Normalize the fractional part 1 will always be on the left side of the binary point
8 Special Single Cases Two zeros –Signed zero –e = 0, f = 0 (exponent and fractional bits are all 0) –(-1) s x –0x (+0) –0x (-0)
9 Special Single Cases Positive infinity –+INF –s = 0, e = 255, f = 0 (all fractional bits are all 0) x7f Negative infinity –-INF –s = 1, e = 255, f = 0 (all fractional bits are all 0) xff
10 Special Single Cases Not-A-Number (NaN) –s = 0 | 1, e = 255, f != 0 (at least one fractional bit is NOT 0) –There are many representations for NaN –Here is one example x7fc0 0000
11 Special Single Cases Maximum single number – –0x7f7f ffff – x Minimum positive single number – –0x – x To represent larger numbers
12 Double Precision IEEE standard 754 –Floating point number representation –64-bit s eeeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffff –s: (1) sign bit 0 means positive, 1 means negative sexponentsignificand significand 310
13 Single Precision s eeeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffff –e: (11) exponent bits [-1022 … 1023] A bias of 1023 is added to the exponent –f: (53) fractional part [52 bits + 1 implied bit] Normalize the fractional part 1 will always be on the left side of the binary point
14 Real (Decimal) Number Storage Double precision floating point numbers –s: (1) sign bit –e: (11) exponent bits [-1022 … 1023] –f: (53) fractional part [52 bits + 1 implied bit] seeeeeeeeee f f f ff f f f Byte f f f f Byte
15 Special Double Cases Two zeros –Signed zero –e = 0, f = 0 (exponent and fractional bits are all 0) –(-1) s x bits … 0000 –0x (+0) … 0000 –0x (-0)
16 Special Double Cases Positive infinity –+INF –s = 0, e = 2047, f = 0 (all fractional bits are all 0) … x7ff Negative infinity –-INF –s = 1, e = 2047, f = 0 (all fractional bits are all 0) … xfff
17 Special Double Cases Not-A-Number (NaN) –s = 0 | 1, e = 2047, f != 0 (at least one fractional bit is NOT 0) –There are many representations for NaN –Here is one example … x7ff
18 Special Double Cases Maximum double number – … 1111 –0x7fef ffff ffff ffff – x Minimum positive single number – … 0000 –0x – x –Don’t forget about the implied 1 bit!!
19 Decimal to Float Conversion Show – in IEEE single precision format –First, save sign (negative so 1) and convert to binary… – = x 2 0 –Normalize… – = x 2 4 –Strip 1 off the mantissa and extend to form significand – = –Bias the exponent… –Exp + Bias = = 131 =
20 Real (Decimal) Number Storage Hex value : 0xC1C10000 Link me baby