The other day, a couple of co-workers and I were talking about whether it was reasonable to expect a user to know the maximum number represented by a 32-bit integer (2147483647 if it’s signed, 4294967295 if not).

A lot of engineers and technical-oriented people tend to know roughly “2 billion” and “4 billion”. But I was in the camp tending towards “No, we should be more explicit for end users”. So, as an experiment, I asked people if they knew the nearest power of 10 for the largest 64-bit integer off the top of their heads.

Discussion about estimating this for a general N-bit integer ensued, and Jim mentioned a pretty decent trick. The logarithm of 10 to the base 2 is a bit less than 3 1/3, so that’s not a bad approximation. So to get the nearest power of 10 for 2^{64} , divide 64 by 10/3 , i.e multiply by 3 and shift the decimal point to the left. So, the nearest power of 10 for the largest 64-bit (unsigned) integer is ⌊(64 * 3) / 10⌋ = 19. The correct answer is 1.8446744e+19, so we are pretty close.

❧ Suggestions, comments, etc. can be emailed to `comments@mandarg.com`

.