| Outcome | Probability | Product |
| 1 | 1/6 | 1/6 |
| 2 | 1/6 | 2/6 |
| 3 | 1/6 | 3/6 |
| 4 | 1/6 | 4/6 |
| 5 | 1/6 | 5/6 |
| 6 | 1/6 | 6/6 |
| Total: | 21/6 | |
1 0 1 1 1 0 1 0 1
256 128 64 32 16 8 4 2 1
Now, the decimal equiv of this number is 256 + 64 + 32 + 16 + 4 + 1 = 373.
| Letter | Probability |
| A | 0.18 |
| B | 0.01 |
| C | 0.16 |
| D | 0.14 |
| E | 0.32 |
| F | 0.10 |
| G | 0.03 |
| H | 0.06 |
| Letter | Code | Length | Probability | Product |
| A | 000 | 3 | 0.18 | 0.54 |
| B | 01100 | 5 | 0.01 | 0.05 |
| C | 100 | 3 | 0.16 | 0.48 |
| D | 101 | 3 | 0.14 | 0.42 |
| E | 11 | 2 | 0.32 | 0.64 |
| F | 010 | 3 | 0.1 | 0.3 |
| G | 01101 | 5 | 0.03 | 0.15 |
| H | 0111 | 4 | 0.06 | 0.24 |
| Total (expected length): | 2.82 | |||
The expected letter length is 2.82, which is less than the 3.0 bits per letter that would be required by a fixed length code - it's about 6% better (3-2.82)/3.