public static double mod(double n, double d) {if (d == 0) {return Double.NaN;}else if (sign(n) == sign(d)) {return n % d;}else {return ((n % d) + d) % d;}}

public static double mod ( double n , double d ) { if ( d == 0 ) { return Double . NaN ; } else if ( sign ( n ) == sign ( d ) ) { return n % d ; } else { return ( ( n % d ) + d ) % d ; } }
public static double Mod(double n, double d){double result = 0;if (d == 0){result = double.NaN;}else if (Sign(n) == Sign(d)){result = n % d;}else{result = ((n % d) + d) % d;}return result;}
