|
|
|
|
|
by mananaysiempre
462 days ago
|
|
This is perfectly usable, of course, but I’d write var actualSize = Integer.highestOneBit(approxSize - 1) << 1;
purely to avoid involving the horrors that live beneath the humble pow() and log().(Integer.highestOneBit, also known as “isolate leftmost bit”, “most significant one”, or the like, essentially has to be a primitive to be efficient, unlike its counterpart for the lowest bit, x&-x. The actual CPU instruction is usually closer to Integer.numberOfLeadingZeros, but that’s just a bitshift away.) |
|