title: Java integer division doesn't give floor for negative numbers
body: <p>I was trying to use java's integer division, and it supposedly takes the floor. However, it rounds towards zero instead of the floor.</p>
  
  <pre><code>public class Main {
      public static void main(String[] args) {
          System.out.println(-1 / 100); // should be -1, but is 0
          System.out.println(Math.floor(-1d/100d)); // correct
      }
  }
  </code></pre>
  
  <p>The problem is that I do not want to convert to a double/float because it needs to be efficient. I'm trying to solve this with a method, <code>floorDivide(long a, long b)</code>. What I have is:</p>
  
  <pre><code>static long floorDivide(long a, long b) {
      if (a &lt; 0) {
          // what do I put here?
      }
      return a / b;
  }
  </code></pre>
  
  <p>How can I do this without a double/float?</p>