Lecture 2: Floating-point number representation
Download
Report
Transcript Lecture 2: Floating-point number representation
FLOATING-POINT NUMBER
REPRESENTATION
Dr. Konstantinos Tatas
ACOE161 - Digital Logic for
Computers - Frederick University
1
The range/accuracy problem
• The range of numbers that can be
n
2
represented with n bits is
• In 2’s complement: from - 2 n/2 to 2 n/2 -1
• For n=8: From –128 to +127
• For n=16: From –32,768 to +32,767
• Still, in many application an even larger
range is required
ACOE161 - Digital Logic for
Computers - Frederick University
2
Real numbers
M b
e
• Instead of representing the actual value, in the
base system, we represent the sign, M, b and e
• 3 105 300000
• 2.5 106 2500000
2
4
10
0.04
•
ACOE161 - Digital Logic for
Computers - Frederick University
3
FLOATING-POINT
REPRESENTATION
• Sign (S) Biased exponent (E) Unsigned normalized mantissa (M)
• F (1) S M E (1) S 1.M 2 E bias
• IEEE short real: 8 bits for the exponent (in Ex127), 23 bits for the mantissa
• IEEE long real: 11 bits for the exponent, 52
bits for the mantissa
ACOE161 - Digital Logic for
Computers - Frederick University
4
RESERVED VALUES
ACOE161 - Digital Logic for
Computers - Frederick University
5
Examples (IEEE short real format)
Binary
value
Normalized
Binary value
exponent
Biased
Sign, exponent, mantissa
Exponent
(Excess -127
-1.01
-1.01
0
127
1 01111111 0100000000000000000000
+1011.0101
+1.0110101
+3
130
0 01000010 0110101000000000000000
-0.0000011
-1.1
-6
121
1 01111001 1000000000000000000000
+11010101
+1.11010101
+7
134
0 10000110 1101010100000000000000
ACOE161 - Digital Logic for
Computers - Frederick University
6
Homework
• Convert the following 2’s complement
values to IEEE short real floating-point
representation
–
–
–
–
10011010
0110.0101
0.1111110
1100.0001
ACOE161 - Digital Logic for
Computers - Frederick University
7