CSC 382 · Computer Architecture 1
Our notes
1 min readFloating point
A real number is stored as sign, exponent and fraction (mantissa): value = (−1)^s × 1.f × 2^(e − bias).
IEEE 754 single precision (32 bits)
| Part | Bits | Notes |
|---|---|---|
| Sign | 1 | 0 positive, 1 negative |
| Exponent | 8 | stored with a bias of 127 |
| Fraction | 23 | the leading 1 is not stored (hidden bit) |
Double precision uses 1, 11 (bias 1,023) and 52 bits.
Worked example: storing −6.75
- 6.75 = 110.11 in binary.
- Normalise: 1.1011 × 2².
- Sign = 1; exponent = 2 + 127 = 129 = 1000 0001; fraction = 1011 followed by 19 zeros.
- Bits: 1 10000001 10110000000000000000000 = C0D8 0000 in hex.
Check: (−1) × 1.6875 × 4 = −6.75 ✓.
Special values
- Exponent all 0 and fraction 0: zero (+0 and −0).
- Exponent all 0, fraction not 0: denormal (very small) numbers.
- Exponent all 1, fraction 0: infinity.
- Exponent all 1, fraction not 0: NaN (not a number, from 0/0).
Precision and rounding
Single precision gives about 7 decimal digits; double about 15-16. Many decimals have no exact binary form: 0.1 = 0.000110011001100... repeating, so 0.1 + 0.2 is not exactly 0.3 in a computer. Never test two reals for exact equality; check that their difference is tiny.
Character codes
- ASCII (7 bits): 'A' = 65 (41 hex), 'a' = 97 (61 hex), '0' = 48 (30 hex). Upper and lower case differ by 32 (one bit).
- EBCDIC (8 bits) on IBM mainframes.
- Unicode gives every character in every script a code point (U+0041 is 'A'; U+1EB9 is 'ẹ'). UTF-8 stores code points in 1 to 4 bytes and keeps ASCII unchanged.
Parity and error detection
A parity bit makes the number of 1s even (even parity) or odd. 'A' = 100 0001 has two 1s: with even parity the parity bit is 0. A single flipped bit is detected, two flips are not.
Exams usually ask
- Convert a decimal number to IEEE 754 single precision and back.
- Explain bias, the hidden bit and special values.
- Give ASCII codes and explain parity.
Common mistake
Forgetting the bias. The exponent field holds the true exponent plus 127, so 2² is stored as 129.
Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.
No reading links here yet
Our team adds free books, videos and practice for each topic, and opens every link before it goes up.