Title: Floating Point Numbers
1Floating Point Numbers
Chapter 5
2Exponential Notation
- The following are equivalent representations of
1,234
123,400.0 x 10-2 12,340.0 x 10-1 1,234.0
x 100 123.4 x 101 12.34 x 102
1.234 x 103 0.1234 x 104
The representations differ in that the decimal
place the point -- floats to the left or
right (with the appropriate adjustment in the
exponent).
p. 122
3Parts of a Floating Point Number
p. 123
4Figure 5.1 Excess-50 representation
5Figure 5.2 Regions of overflow and underflow
6Figure 5.4 Typical floating point format
7IEEE 754 Standard
- Most common standard for representing floating
point numbers - Single precision 32 bits, consisting of...
- Sign bit (1 bit)
- Exponent (8 bits)
- Mantissa (23 bits)
- Double precision 64 bits, consisting of
- Sign bit (1 bit)
- Exponent (11 bits)
- Mantissa (52 bits)
8Single Precision Format
32 bits
9Double Precision Format
64 bits
kc
10Normalization
- The mantissa is normalized
- Has an implied decimal place on left
- Has an implied 1 on left of the decimal place
- E.g.,
- Mantissa
- Representation
10100000000000000000000 1.1012 1.62510
11Excess Notation
- To include both positive and negative exponents,
excess-n notation is used - Single precision excess 127
- Double precision excess 1023
- The value of the exponent stored is n larger than
the actual exponent - E.g., excess 127,
- Exponent
- Representation
10000111 135 127 8 (value)
Ed kc
12Excess Notation- Sample -
Represent exponent of 1410 in excess 127 form
12710 011111112 1410
000011102 Representation 100011012
Ed kc
kc
13Excess Notation- Sample -
Represent exponent of -810 in excess 127 form
12710 011111112 - 810 -
000010002 Representation
011101112
Ed kc
kc
14Example
0 10000010 11000000000000000000000
15Exercise Floating Point Conversion (1)
- What decimal value is represented by the
following 32-bit floating point number? - Answer
1 10000010 11110110000000000000000
Skip answer
Answer
16Exercise Floating Point Conversion (1)
Answer
- What decimal value is represented by the
following 32-bit floating point number? - Answer -15.6875
1 10000010 11110110000000000000000
17Step by Step Solution
1 10000010 11110110000000000000000
To decimal form
130 - 127 3
1.11110110000000000000000000
1 .5 .25 .125 .0625 0 .015625
.0078125
1.9609375
23
15.6875
- 15.6875
( negative )
18Step by Step Solution Alternative Method
1 10000010 11110110000000000000000
To decimal form
130 - 127 3
1.11110110000000000000000000
1111.10110000000000000000000
Shift Point
- 15.6875
( negative )
kc
19Exercise Floating Point Conversion (2)
- Express 3.14 as a 32-bit floating point number
- Answer
- (Note only use 10 significant bits for the
mantissa)
Skip answer
Answer
20Exercise Floating Point Conversion (2)
Answer
- Express 3.14 as a 32-bit floating point number
- Answer
- (Note only use 10 significant bits for the
mantissa)
0 10000000 10010001111000000000000
21Figure 5.6 IBM floating point formats
22Figure 5.7 Alpha floating point formats
23Detail Solution 3.14 to IEEE double precision
3.14 To Binary (approx)
11.001000111101
Delete implied left-most 1 and normalize
1001000111101
Poof !
Exponent 127 1 position point moved when
normalized
10000000
Value is positive Sign bit 0
0 10000000 10010001111010000000000
24Packed Decimal Format - 1 of 4
Somewhat limited use e.g Where precision
particularly important, as in accounting
functions. Similar to BCD e.g Four bit
representation, as in BCD. -gt Stores two
digits per byte.
kc
25Packed Decimal Format - 2 of 4
Stores up to 31 digits Last four bits
for sign - 1100 -gt positive - 1101 -gt
negative - 1111 -gt unsigned Decimal Point
not stored must be maintained by separate
(application) software.
kc
26Packed Decimal Format - 3 of 4
Example Decimal Value 10357, unsigned Packed
Decimal 0001 0000 0011 0101 0111 1111
Byte 1 Byte 2 Byte 3
kc
27Packed Decimal Format - 4 of 4
Example Decimal Value - 90413 Packed
Decimal 1001 0000 0100 0001 0011 1101
Byte 1 Byte 2 Byte 3
kc
28Figure 5.8 Packed decimal format
29Thank you
Thats all this time !!