The opposite of 2 ^ n <p>The function a = 2 ^ b can quickly be calculated for any b by doing <code>a = 1 &lt;&lt; b</code>. What about the other way round, getting the value of b for any given a? It should be relatively fast, so <strong>logs are out of the question</strong>. Anything that's not O(1) is also bad.</p> <p>I'd be happy with <em>can't be done</em> too if its simply not possible to do without logs or a search type thing.</p>