1 Number Representation
Number Representationβ
Unsignedβ
Signed-Magnitudeβ
"first" bit gives sign, rest treated as unsigned (magnitude)
Biased Notationβ
The actual value is the binary value plus a fixed bias
Twoβs Complementβ
Logical Operationsβ
Shift operations
- Left Shift: throw away extra bits on left, fill with 0's on the right
- Right Shift: throw away extra bits on right
- logical shift: fill with 0's on the left
- arithmetic shift: replicate most significant bit(x >> k gives towards negative infinity)
Floating Point Representationβ
Definitionβ
S represents Sign
1 for negative, 0 for positive
Significand
implicit leading 1, signed-magnitude (not 2βs complement)
Exponent(biased notation)
Idea: we want floating point numbers to look small when their actual value is small
(bias of 127 for 32bits, 1023 for 64bits)
Special Casesβ
Exponent(Biased) | Significand | Object |
---|---|---|
0 | 0 | |
0 | nonzero | Denorm |
1-254 | aynthing | Normal Floating Point |
255 | 0 | |
255 | Nonzero | NaN |
Overflow and Underflowβ
- Overflow (or)
- Underflow ( without 0)
0,infinite and NANβ
- 0:Bit pattern all 0s
- ()
- Sign bit 0 or 1, largest exponent (all 1s), 0 in fraction
- NaN(,)
- Sign bit 0 or 1, largest exponent (all 1s), not zero in fraction
op(NaN, X) = NaN
Demormsβ
Denormalized number:
- no (implied) leading 1(just Significand),frac nonzero
- exponent all 0,value = 1 β Bias (instead of 0 β Bias)
Special Cases:
- Smallest denorm:
- Largest denorm:
- Smallest norm:
- Largest norm: