code: private static long divideAndRound(long ldividend, long ldivisor, int roundingMode) {
          int qsign; // quotient sign
          long q = ldividend / ldivisor; // store quotient in long
          if (roundingMode == ROUND_DOWN)
              return q;
          long r = ldividend % ldivisor; // store remainder in long
          qsign = ((ldividend < 0) == (ldivisor < 0)) ? 1 : -1;
          if (r != 0) {
              boolean increment = needIncrement(ldivisor, roundingMode, qsign, q,     r);
              return increment ? q + qsign : q;
          } else {
              return q;
          }
      }
docs: Divides {@code long} by {@code long} and do rounding based on the
  passed in roundingMode.