title: How to find antilog(base 2) of a number?
body: <p>I used a for loop to find antilog of the given number.</p>
  
  <pre><code>int g = 0, m, diff = 10;
  for(j = 0; g &lt;= diff; j++)
  {
      g = pow(2, j);
  }
  m = j - 2;
  cout &lt;&lt; m;
  </code></pre>
  
  <p>It gives the power of 2 for which <code>g</code> is the number just less than <code>diff</code>.</p>
  
  <p>I tried the base change theorem of log to find the antilog of the number something like this:</p>
  
  <pre><code>m = log(diff) / log(2);
  </code></pre>
  
  <p>without the for loop, but in this case whenever there is a number that is an exact multiple of 2s for example 8, then it gives 2 as the answer and not 3.</p>
  
  <p>And using for loop for doing so is in a program is exceeding the time limit.</p>
  
  <p>Is there a shorter and reliable way to do so?</p>