* @param modulus
   * @return double
   */
  public static double fmod(double x, double modulus) {
    { double remainder = (x % modulus);

      if (remainder > 0.0) {
        if (modulus < 0.0) {
          remainder = modulus + remainder;
        }
      }
      else if (remainder < 0.0) {
        if (modulus > 0.0) {
          remainder = modulus + remainder;
        }
      }
      return (remainder);
    }
  }