Here you can find the source of fmod(double a, double b)
public static double fmod(double a, double b)
//package com.java2s; //License from project: Open Source License public class Main { public static double fmod(double a, double b) { double mod = a % b; if (mod < 0) { mod += b;//from ww w . j av a2 s . c om } return mod; } }