← Back to context

Comment by zeroonetwothree

2 years ago

The “common” units are powers of 10 so this doesn’t work

The original SO question did actually state they wanted powers of two (kilobyte as 1024 bytes). Although, they should have used KiB, GiB, instead to be pedantic.

But you can avoid binary search because there are at most one power of tens between 2^k and 2^(k+1). So you can turn it into a lookup table problem.