Loading
Computers store real numbers as : a sign bit, a biased exponent and a fraction. Most decimals (like ) have endless binary expansions, so the nearest representable number is stored, with a small rounding error.
Store in single precision (32 bits).
Read the remainders from the bottom up: .
Read the whole parts from the top down: , so .
| Part | Bits | Why |
|---|---|---|
| Sign (1 bit) | 1 | the number is negative |
| Exponent (8 bits) | 10000010 | 130 = 3 + 127 |
| Fraction (23 bits) | 10110100000000000000000 | the bits after "1." in 1.101101, padded with zeros |
Grouped in fours: 1100 0001 0101 1010 0000 … = C15A0000 in hex. The fraction ended within 23 bits, so the number is stored exactly.
The calculator below opens on 0.1, which cannot be stored exactly: its binary fraction 0.000110011… never ends, so it is rounded.
Storing the leading 1.
Forgetting the bias.
Reading the remainders in the wrong order.
Putting the minus sign into the exponent or fraction.
Thinking every decimal is exact.
Wrong count of bits.
Type a decimal number.
Add this calculator to a new note, next to your own working. It stays live: change the numbers there any time.