Here you can find the source of mod(final double a, final double b)
public static double mod(final double a, final double b)
//package com.java2s; //License from project: Apache License public class Main { public static double mod(final double a, final double b) { double val = a; while (val >= b) { val -= b; }/*w w w .j av a 2 s . c o m*/ while (val < 0.0) { val += b; } return val; } }