title: How to convert float to int with Java
body: <p>I used the following line to convert float to int, but it's not as accurate as I'd like:</p>
  
  <pre><code> float a=8.61f;
   int b;
  
   b=(int)a;
  </code></pre>
  
  <p>The result is : <code>8</code> (It should be <code>9</code>)</p>
  
  <p>When <code>a = -7.65f</code>, the result is : <code>-7</code> (It should be <code>-8</code>)</p>
  
  <p>What's the best way to do it ?</p>