code: public static int floorDiv (int dividend, int divisor)
      {
          return ((dividend >= 0) == (divisor >= 0)) ?
              dividend / divisor : (divisor >= 0 ?
                      (dividend - divisor + 1) / divisor : (dividend - divisor - 1) / divisor);
      }
docs: Computes the floored division <code>dividend/divisor</code> which
  is useful when dividing potentially negative numbers into bins.
  
  <p> For example, the following numbers floorDiv 10 are:
  <pre>
  -15 -10 -8 -2 0 2 8 10 15
  -2  -1 -1 -1 0 0 0  1  1
  </pre>