Académique Documents
Professionnel Documents
Culture Documents
Fractional Numbers
fixed-point notation
floating-point notation
Fixed-point Notation
Fixed-point Notation
If needed:
fractional
Examples
Fixed-point Notation
Fixed-point Notation
Examples
sign (1 bit)
integer part (m bits)
fractional part (n-m-1 bits)
E.g. 1+7+8 means 1 bit for sign, 7 for the
integer part and 8 for the fractional part
01100010
01100010 10011110
Note: when using the 1st 2C-operation method,
1 must be added to the LSB, not to unity place:
01100010
2C-Operation
10011101+
1=
10011110
Exercises
151.0
FX 2C on 16 bits (1+8+7)
151.25
FX 2C on 16 bits (1+8+7)
111100101010 from FX 2C (1+7+4) ()10
100110011000 from FX 2C (1+6+5) ()10
(111.6 44.57) / 2
(68.22 71.25) * 64
Exercises
Solutions
0 10010111 0000000
1 01101001 0000000
151.25
0 10010111 0100000
1 01101000 1100000
Note that the integer part is not the same
111100101010
0 0001101 0110
13.37510
100110011000
0 110011 01000
51.2510
151.0
Exercises
10
Exercises
Solutions
(111.6 44.57) / 2
1101111.10011001201101111100110012C
101100.100100012 00101100100100012C
11010011011011112C
1 0110111110011001+
1101001101101111=
0100001100001000 0010000110000100
+33.515625
(68.22 71.25) * 64
1000100.00111000201000100001110002C
1000111.012
01000111010000002C
10111000110000002C
1 0100010000111000+
1011100011000000=
1111110011111000 0011111000000000
OVERFLOW
Solutions
11
Fixed-point Uses
12
Fixed-point Problems
37.25
12.625
5.4375
1.2890625
100101.01
1100.1010
101.01110
1.0100101
13
Fixed-point Problems
Fixed-point Problems
7.2732
2.3748
5.4375
14
1.2890
15
Fixed-point Problems
16
Exponential Notation
Exponent
123.45678 = 0.12345678103
0.0087654321 = 0.8765432110-2
87655678 = 0.87655678108
17
Exponential Notation
Exponential Notation
18
normalized form
0.001234567 0.123410-2=0.001234000
876543 0.8765106 = 876500
19
Exponential Notation
20
Exponential Notation
Example
21
Exponential Notation
IEEE-P754 Floating-Point
Example
22
23
sign: 1 bit
exponent field: 8 bits
mantissa (or significand) field: 23 bit
s exponent
mantissa
24
25
26
27
28
sign bit = 1
extract the mantissa, add the hidden bit,
and convert to decimal
1.012= 1.2510
compute the real exponent by subtracting
127 from the extracted exponent
1100000 = 96 96127=31
compose the parts: -1.2510231 =-5.821010
29
30
1.10010..1 20
1.10010..1 25
1.10010..1 294
= 20-23 = 2-23
= 25-23 = 2-18
= 294-23 = 271
31
Zeroes
Infinities
NaNs
Denormalized values
32
Zero
Exponent=00000000, Mantissa=0
0/1 0000 0000
by definition, not by computation, because
there is not any 1 for normalization
Positive and negative are considered
equivalent
Infinity
Exponent=11111111, Mantissa=0
0/1 1111 0000
Operations with infinitives are well defined
33
34
Special Operations
N / INF
INF INF
N/0
INF + INF
0/0
INF INF
INF / INF
INF 0
=0
= INF
= INF
= INF
= NaN
= NaN
= NaN
=NaN
35
36
exponent bits: 11
mantissa bits: 52
bias constant: 1023
exponent range: 1022, +1023
equivalent decimal range:
(4.910-324 1.710+308)
with 15 decimal digits
denormalized exponent: 1022
37
IEEE-P754 Exercises
38
1324.25 to SP and DP
0.02324 to SP and DP with an absolute
precision of 1/1000
39
IEEE-P754 Exercises
Solutions
1324.25
10100101100.01 = 1.010010110001210
then:
40
IEEE-P754 Exercises
Solutions
0.02324
= 1/1000 n =10 (fractional bits)
0.0000010111 = 1.011126
then:
41
IEEE-P754 Exercises
Floating-point Addition
Solutions
42
0 10000000 0010000
+1.00122128-127= 10.012 =+2.25
1 01111111 1100000
1.1122127-127= 1.75
EB141000 = 1 11010110 0010100000100
1.0010122214-127= 1.1562510287=
= 1.1562510287 = 1.15625 280 27=
1 1024 102 = 1026 (approx.)
the non-approximated value is:
1.78921021302965117856514048 1026
43
Underflow
44
Underflow
Example in SP
1.101243+ 1.01218
1.01218 must be converted to the form
xxx243, this causes a right shift of 25
bits on the mantissa, thus shifting away
all the 24 mantissa bits and resulting in 0
Adding up many small values, it is
possible that a partial sum becomes so
big to cause underflow for each of the
subsequent values (only the first part of
the values is added up)
45
IEEE-P754 Exercises
IEEE-P754 Exercises
46
Solution N.1:
2B1A5F20 + 4F1A3BB0
C4A58000 + C2B80000
63AB102F 709B1BC2
7F600000 + 7F100000
2B1A5F20
0 01111110 00110100101111100100000
E=01010110=86
4F1A3BB0
0 10011110 00110100011101110110000
E=10011110=158
Difference of exponents= 72
72 > 24 UNDERFLOW
Result: 4F1A3BB0
47
IEEE-P754 Exercises
Solution N.2:
C4A58000
1 10001001 01001011000000000000000
E=10001001 =137 (non biased: 10)
M=1. 01001011
C2B80000
1 10000101 01110000000000000000000
E=10000101 =133 (non biased: 6)
M=1.0111
Difference of exponents: 137 133= 4
48
IEEE-P754 Exercises
49
IEEE-P754 Exercises
IEEE-P754 Exercises
Solution N.3
50
63AB102F 709B1BC2
0 11000111 01010110001000000111111
E=199
0 11100001 00110110001101111000010
E=225
Difference of exponents: 225 199 = 26
26 > 24 UNDERFLOW
Result: F09B1BC2 (SIGN CHANGED!)
Solution N.4
7F600000
0 11111110 11000000000000000000000
E=254 (non biased=127)
7F100000
0 11111110 00100000000000000000000
E=254 (non biased=127)
Difference of exponents: 0
51
IEEE-P754 Exercises
1.110 2127 +
1.001 2127 =
10.111 2127
Renormalization: 1.01112128
Max exponent is 127 OVERFLOW
Result: (+Infinity)
0 11111111 00000000000000000000000
7F800000
52
IEEE-P754 Exercises
92000000010 92000000110
53
IEEE-P754 Puzzles
IEEE-P754 SP Ranges
Solution:
54
55
IEEE-P754 SP Ranges
56
IEEE-P754 SP Ranges
3.4028234663852885981170418348452e+38
1.1754943508222875079687365372222e38
57
IEEE-P754 Puzzles
IEEE-P754 Puzzles
58
59
IEEE-P754 Puzzles