code: private static int div(int a, int b) {
      return a > 0 ? (b > 0 ? a / b : (a - b - 1) / b)
                   : (b > 0 ? (a - b + 1) / b : a / b);
    }
docs: Implementation of the XSD div operation, which differs from Java integer division in that it rounds
  down for negative quotients while Java rounds up, i.e.:
  -1 / 2 == 0
  div(-1, 2) == -1