Here you can find the source of mod(double value, double mod)
public static double mod(double value, double mod)
//package com.java2s; //License from project: Apache License public class Main { public static double mod(double value, double mod) { if (value < 0 || mod <= 0) throw new IllegalArgumentException("value must be >= 0"); int index = (int) (value / mod); value -= mod * index;/*w ww . j av a2 s . c o m*/ if (value < 0) return 0; else if (value >= mod) return 0; else return value; } }