- Number of distinct values (N)
- 1000
10bit
Open with these values10bit
Result: 10 bitBits = ⌈log₂N⌉, always rounded up, because there is no such thing as 9.97 of a bit. Labelling 1000 values takes 10 bits: 9 bits cover only 512 patterns, 10 bits cover 1024. One single value takes 0 bits.
10bit
Open with these values8bit
Open with these values11bit
Open with these valuesbits = ⌈log₂N⌉
log₂1000 comes out at 9.97, and 0.97 of a bit does not exist. The answer is 10, because 9 bits label only 512 patterns.
One bit covers 2 values, 8 bits cover 256 and 10 bits cover 1024. Counting from zero, the largest value n bits can carry is 2ⁿ − 1.
The integers 0 through 999 are 1000 values, which needs 10 bits. If you only know the largest value M and count from zero, enter M + 1.
1024 values still fit in 10 bits, but 1025 need 11. The jump happens immediately after every power of two.
Round 9.97 bits to whichever whole number is closer.
Always upwards. Rounding down would leave part of the values without a pattern of their own.
A single value still needs one bit.
It needs none, since log₂1 is 0 and there is nothing to tell it apart from. Bits start being necessary at two values.
Twice as many values costs twice as many bits.
Doubling costs exactly one extra bit. 512 values take 9 bits, 1024 take 10.
| Values (N) | Nearest power of two | Bits |
|---|---|---|
| 1 | nothing to distinguish | 0 |
| 2 | exactly 2¹ | 1 |
| 3 | past 2¹ | 2 |
| 16 | exactly 2⁴ | 4 |
| 100 | past 2⁶ | 7 |
| 256 | exactly 2⁸ | 8 |
| 1000 | past 2⁹ | 10 |
| 1024 | exactly 2¹⁰ | 10 |
| 1025 | past 2¹⁰ | 11 |
Take the base-2 logarithm of N and round up: bits = ⌈log₂N⌉. Labelling 1000 distinct values needs ⌈9.97⌉ = 10 bits, because 9 bits cover only 512 patterns while 10 bits cover 1024.
Bits come in whole units — you cannot store 9.97 of a bit. Rounding down would leave some values without a unique pattern. Only when N is an exact power of two does the logarithm come out whole and no rounding is needed.
Exactly 2ⁿ. One bit covers 2 values, 8 bits cover 256, and 10 bits cover 1024. Every extra bit doubles the count, which is why bit counts grow slowly even as the number of values explodes.
With one possible value there is nothing to distinguish it from, and log₂1 is 0. You only start needing bits once there are at least two values to tell apart.
The count of distinct values. To store the integers 0 through 999 you have 1000 values, so ⌈log₂1000⌉ = 10 bits. If you know the largest value M and count from 0, enter M + 1.
Information, not professional advice.
Diese Seite gibt es auch auf Deutsch.
Zu Deutsch wechseln