title: How to convert a float to an int in modern C++
body: <p>As strange as it may seems, I can't find how to cleanly convert a <code>float</code> to an <code>int</code>.</p>
  
  <p>This technique </p>
  
  <pre><code>int int_value = (int)(float_value + 0.5);
  </code></pre>
  
  <p>triggers a </p>
  
  <pre><code>warning: use of old-style cast
  </code></pre>
  
  <p>in gcc.</p>
  
  <p>So, what is the modern-style, simple way to convert a <code>float</code> to an <code>int</code> ? (I accept the loss of precision of course)</p>