Colours
How many different colours can you encode if you have 3 digits per pixel? (no
checkbit)
000
|
001 |
010 |
011 |
100 |
101 |
110 |
111 |
- In 3 digits, you can have 8 different numbers, 0 to 7.
- In n digits, you can have 2^n different numbers, 0 to (2^n)-1.
How many different colours can you encode if you have 3 digits per pixel and
a checkbit?
- One bit is "wasted" with the checkbit. It is the red digit out
front.
- This leaves the other 2 digits to hold the numbers. You have 4 numbers,
0 to 3.
- In n digits, you can have 2^(n-1) different numbers.
Integers (positive and negative)
How many integers can you store in 3 bits?
111 |
110 |
101 |
000 |
001 |
010 |
011 |
| -3 |
-2 |
-1 |
0 |
1 |
2 |
3 |
- In 3 digits, you can store 7 numbers, -3 to 3.
- In n digits, you can store (2^n)-1 digits, -((2^(n-1))-1) to +((2^(n-1))-1)
How many integers can you store in 4 bits, including a checkbit?
1111 |
0110 |
0101 |
0000 |
1001 |
1010 |
1011 |
| -3 |
-2 |
-1 |
0 |
1 |
2 |
3 |
- One bit is "wasted" with the checkbit. It is the red digit out
front.
- In 4 digits, you can store 7 numbers, -3 to 3.
- In n digits, you can store (2^(n-1))-1 digits, -((2^(n-2))-1) to +((2^(n-2))-1)