title: Fast ceiling of an integer division in C / C++
body: <p>Given integer values <code>x</code> and <code>y</code>, C and C++ both return as the quotient <code>q = x/y</code> the floor of the floating point equivalent.  I'm interested in a method of returning the ceiling instead.  For example, <code>ceil(10/5)=2</code> and <code>ceil(11/5)=3</code>.</p>
  
  <p>The obvious approach involves something like:</p>
  
  <pre><code>q = x / y;
  if (q * y &lt; x) ++q;
  </code></pre>
  
  <p>This requires an extra comparison and multiplication; and other methods I've seen (used in fact) involve casting as a <code>float</code> or <code>double</code>.  Is there a more direct method that avoids the additional multiplication (or a second division) and branch, and that also avoids casting as a floating point number?</p>