Here you can find the source of mod(double x, double y)
public static double mod(double x, double y)
//package com.java2s; public class Main { /**/* www . ja v a 2 s .co m*/ * Returns the given number modulo the second number (mod for floats). */ public static double mod(double x, double y) { return x - y * Math.floor(x / y); } /** * Truncate x down to the nearest y. */ public static double floor(double x, double y) { return y * Math.floor((x + .00001) / y); } }