Lecture5 COA
Lecture5 COA
Pilani Campus
DS RAO
COA -IS ZC353
IMP Note to Self
IMP Note to Students
It is important to know that just login to the session does not
guarantee the attendance.
Once you join the session, continue till the end to consider
you as present in the class.
IMPORTANTLY, you need to make the class more interactive
by responding to Professors queries in the session.
Whenever Professor calls your number / name ,you need
to respond, otherwise it will be considered as ABSENT
Real Numbers
10111111010100000000000000000000
Zero
Exponent field E = 0 and fraction F = 0
+0 and –0 are possible according to sign bit S
Infinity
Infinity is a special value represented with maximum E and
F=0
For single precision with 8-bit exponent: maximum E = 255
Infinity can result from overflow or division by zero
+∞ and –∞ are possible according to sign bit S
+ 1.111001000000000000000102 × 24
+ 1.100000000000001100001012 × 22
Cannot add significands … Why?
+ 1.11100100000000000000010 × 24
+ 0.01100000000000001100001 01 × 24 (shift right)
-------------------------------------------------------------------------------------
+10.01000100000000001100011 01 × 24 (result)
+ 1.00000000101100010001101 × 2-6
– 1.00000000000000010011010 × 2-1
- 0.11110111111110111010101 10011 × 2-1 (result is negative)
Result should be normalized
For subtraction, we can have leading zeros. To normalize,
count the number of leading zeros, then shift result left and
decrement the exponent accordingly.
Guard bit
- 0.11110111111110111010101 1 0011 × 2-1
- 1.11101111111101110101011 0011 × 2-2 (Normalized)
Guard bit
Guard bit: guards against loss of a fraction bit
Needed for subtraction, when result has a leading zero and
should be normalized.
10111110111101111111101110101011
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Rounding to Nearest Even
Normalized result has the form: 1. f1 f2 … fl R S
The round bit R appears after the last fraction bit fl
The sticky bit S is the OR of all remaining additional bits
Round to Nearest Even: default rounding mode
Four cases for RS:
RS = 00 Result is Exact, no need for rounding
RS = 01 Truncate result by discarding RS
RS = 11 Increment result: ADD 1 to last fraction bit
RS = 10 Tie Case (either truncate or increment result)
Consider multiplying:
-1.110 1000 0100 0000 1010 00012 × 2–4
× 1.100 0000 0001 0000 0000 00002 × 2–2
Unlike addition, we add the exponents of the operands
Result exponent value = (–4) + (–2) = –6
Using the biased representation: EZ = EX + EY – Bias
EX = (–4) + 127 = 123 (Bias = 127 for single precision)
EY = (–2) + 127 = 125
EZ = 123 + 125 – 127 = 121 (value = –6)
Sign bit of product can be computed independently
Sign bit of product = SignX XOR SignY = 1 (negative)
Normalize Product:
-10.10111000111110111111001100... × 2-6
Shift right and increment exponent because of carry bit
= -1.010111000111110111111001100... × 2-5
Round to Nearest Even: (keep only 23 fraction bits)
1.01011100011111011111100 | 1 100... × 2-5
Single: (1 + 8 + 23)
Double: (1 + 11 + 52)