Here you can find the source of ModEuclidean(int D, int d)
public static int ModEuclidean(int D, int d)
//package com.java2s; //License from project: Apache License public class Main { public static int ModEuclidean(int D, int d) { int r = D % d; if (r < 0) { if (d > 0) { r = r + d;//from ww w. j ava 2 s. c om } else { r = r - d; } } return r; } }