title: Find out (in C++) if binary number is prefix of another
body: <p>I need a function with a header like this:</p>
  
  <pre><code>bool is_prefix(int a, int b, int* c) {
      // ...
  }
  </code></pre>
  
  <p>If a is, read as a binary number string, a prefix of b, then set *c to be the rest of b (i.e. "what b has more than a") and return true. Otherwise, return false. Assume that binary strings always start with "1".</p>
  
  <p>Of course - it is easy to do by comparing bit by bit (leftshift b until b==a). But is there a solution which is more efficient, without iterating over the bits?</p>
  
  <p>Example: <code>a</code>=100 (4), <code>b</code>=1001 (9). Now set <code>*c</code> to 1.</p>