Normalize Fixed Point Number Normalize 0.00010101 Shift decimal 4 places to right 1.0101 mantissa (normalized) exponent – 4
1 assumed 0101 mantissa
1.0101
To un-normalize, shift decimal 4 places to the left 1.0101 to the original .00010101
CSc 28
10
Bias Notation Represent negative and positive numbers – but to do so, store them so that 000 represents the smallest value and 111 the largest. (1) largest
smallest
k=3 bits 111 110 101 100 011 010 001 000
value 7 6 5 4 3 2 1 0
CSc 28
(3)
(2) Value - 2 3 2 1 0 -1 -2 -3 -4
(k-1)
(2) + 2
(k-1)
7 6 5 4 3 2 1 0
11
Bias Notation – 3 bit exponent Represent negative and positive numbers – but to do so, store them so that 000 represents the smallest value and 111 the largest. (1) largest
smallest
value 7 6 5 4 3 2 1 0
k=3 bits 111 110 101 100 011 010 001 000
(3)
(2) Value - 2 3 2 1 0 -1 -2 -3 -4
(k-1)
(2) + 2
(k-1)
7 6 5 4 3 2 1 0
3 bit exponent shift value applied to Mantissa
12
Positive and Negative Exponents Exponents to be stored: -7 -6 -5 -4
If the exponent to be stored is – 7 e 8, the corresponding characteristic, c, would be c = e + (2k-1 -1) To convert the corresponding characteristic to the exponent: e = c – (2k-1 -1)
CSc 28
e is the shift number k the number of bits used to represent the exponent
(1) - Bias For infinities 127 126 … 2 1 0 -1 -2 … -126 For denorms
18
0.00011 to 1.10000 -4 1000.1 to 1.0001 +4
Normalizing the Mantissa Binary Normalized Exponent Value as e 1101.101 1.101101 +3 0.00101 1.01 -3 1.0001 1.0001 0 10000011 1.0000011 +7
• Shift the binary point so that only one digit appears before the point • The exponent expresses the number of positions the decimal point was moved • The sign: to restore the binary point to its original position; plus (+) means the point must be shifted to the right, minus (– ) means the point must be shifted to the left CSc 28
19
Conversion Procedure 1. If the original number is hex, convert it to binary 2. Separate the sign, exponent and mantissa fields 3. Extract the mantissa and restore the leading one (omit the trailing zeros) 4. Extract the exponent and subtract the bias to get the actual exponent (n) Bias = 2k-1 – 1 where k is the number of bits in the exponent field (3 for the 8-bit format and 127 for the 32-bit format)
5. De-normalize the number: move the binary point n spaces to the right if n is negative or to the left if n is positive. 6. Convert the binary value to decimal. 7. Set the sign of the decimal number according to the sign bit of the original floating point number CSc 28
20
Shift = – 5
Normalize c = (127 + (– 5) = 122)
Normalize .0000101 0.000101 00.00101 000.0101 0000.101 00001.01 Negative exponent means a shift to the left to restore
1111 1111 reserved for infinities or NaN (not a number) e.g divide by zero 0000 0000 reserved not (and cannot be) normalized numbers, smaller than 2 – 126 (left with 0.001 2 -126 which is represented by 0 0000 0000 001000 … 0) CSc 28 33
Your turn… Convert the 32-bit floating point number to decimal Sign bit 0 Exponent 1000 1000 Mantissa 0110 1100 0010 …