educative.io

How did we come up with 9 bits for the Photo ID?

Can you please explain how do we come up with the following 9 bits below when we design the Photo ID? I understand the 31 bits, but this 9 bits is a sudden turn in the flow of thoughts. Appreciate any help.

Quote:
"
What could be the size of our PhotoID ? Let’s say our epoch time starts today, how many bits we would need to store the number of seconds for next 50 years?

86400 sec/day * 365 (days a year) * 50 (years) => 1.6 billion seconds

We would need 31 bits to store this number. Since on the average, we are expecting 23 new photos per second; we can allocate 9 bits to store auto incremented sequence. So every second we can store (2^9 => 512) new photos."

We need to have a complete byte number, so, in total, either we can have 32 bits (4 bytes) or 40 bits (5 bytes).

One average we are expecting 23 new photos per second. We already are using 31 bits and since we can’t store number ‘23’ in one bit, therefore, we should use 9 additional bits (1bit +1byte) to make it to 40 bits.

Thanks for the reply. It is clear now.