title: Rounding double to int always to the smaller
body: <p>I want to convert double values to int values in java. I am encountering the problem that simple casting doesn't work as I want and the Math.round() doesn't do it either.</p>
  
  <p>My goal is that the doubles should be rounded down to the next smaller int. As following:</p>
  
  <pre><code> 0.5 -&gt;  0
   1.7 -&gt;  1
   2.9 -&gt;  2
  -0.3 -&gt; -1
  -3.9 -&gt; -4
  </code></pre>
  
  <p>The problem mostly are the different handling methods smaller than 0. Since I don't want them to round to the higher, but to the lower value.</p>
  
  <p>Is there a java-native function for this, or how can I implement this effectively? I thought of the following, but I'd rather use a java-native function.</p>
  
  <pre><code>double d = -0.1D; // or whatever else
  int i = (double) ((int) d) &lt;= d ? (int) d : (int) d - 1;
  </code></pre>