title: In C bits, multiply by 3 and divide by 16
body: <p>A buddy of mine had these puzzles and this is one that is eluding me. Here is the problem, you are given a number and you want to return that number times 3 and divided by 16 rounding towards 0. Should be easy. The catch? You can only use the ! ~ &amp; ^ | + &lt;&lt; >> operators and of them only a combination of 12. </p>
  
  <pre><code>int mult(int x){
      //some code here...
  return y;
  }
  </code></pre>
  
  <p>My attempt at it has been:</p>
  
  <pre><code>    int hold = x + x + x;
      int hold1 = 8;
      hold1 = hold1 &amp; hold;
      hold1 = hold1 &gt;&gt; 3;
      hold = hold &gt;&gt; 4;
      hold = hold + hold1;
      return hold;
  </code></pre>
  
  <p>But that doesn't seem to be working. I think I have a problem of losing bits but I can't seem to come up with a way of saving them. Another perspective would be nice. Just to add, you also can only use variables of type int and no loops, if statements or function calls may be used.</p>
  
  <p>Right now I have the number 0xfffffff. It is supposed to return 0x2ffffff but it is returning 0x3000000.</p>