code: public static double mod(double a, double div) {
          final double remainder = a % div;
          return remainder < 0 ? remainder + div : remainder;
      }
docs: Returns the modulo of 'a' by 'div' with corrections for negative numbers.
  
  @param a The dividend
  @param div The divider
  @return The corrected modulo