title: How to convert number from double to int without rounding?
body: <p>I want to calculate how many columns can fit into container. First I calculate how many columns can fit in, then I calculate number of margins for them. After that I check if they will fit in with margins, if no - reduce amount of columns by one.
  Code:</p>
  
  <pre><code>int columnMargin = 50;
  double result = columnContainerHBox/minimalColumnWidth;
  int columnCount = (int) result; // here's the problem
  int numberOfMargins = columnCount - 1;
  double finalCount = columnContainerHBox/minimalColumnWidth*columnCount+columnMargin*numberOfMargins;
  if(finalCount&lt;1){
      columnCount--;
  }
  </code></pre>
  
  <p>The problem is that I don't know how to convert from <code>double</code> to <code>int</code> without rounding number. I just need to get rid of all numbers after decimal. I already tried <code>(int) double</code>, <code>(int)Math.floor(double)</code> and <code>new DecimalFormat('#').format(double)</code>. As a <code>double</code> I took 1.99999999999999999999. All above was converting it to 2. Desirable result - 1;</p>
  
  <p>My <code>double</code> is going to be completely random. It can be 1.0, 1.9999999999, 2.45, 3.5959547324 etc. </p>
  
  <p>What I need is to get a whole part and completely discard everything after decimal.</p>