code: public static double mod(double a, double b) {
  		int n = (int)(a/b);
  		
  		a -= n*b;
  		if (a < 0)
  			return a + b;
  		return a;
  	}
docs: Return a mod b. This differs from the % operator with respect to negative numbers.
  @param a the dividend
  @param b the divisor
  @return a mod b