java: public static double floor(double n, double s) {if (s==0 && n!=0) {return Double.NaN;} else {return (n==0 || s==0) ? 0 : Math.floor(n/s) * s;}}
C#: public static double Floor(double n, double s){double f;if ((n < 0 && s > 0) || (n > 0 && s < 0) || (s == 0 && n != 0)){f = double.NaN;}else{f = (n == 0 || s == 0) ? 0 : Math.Floor(n / s) * s;}return f;}