Here you can find the source of modulo(int x, int m)
public static final int modulo(int x, int m)
//package com.java2s; //License from project: Open Source License public class Main { public static final int modulo(int x, int m) { azzert(m > 0, "m must be > 0"); int y = x % m; if (y < 0) { y += m;/* w ww . ja v a 2 s .com*/ } return y; } public static void azzert(boolean expr) { if (!expr) { throw new AssertionError(); } } public static void azzert(boolean expr, String message) { if (!expr) { throw new AssertionError(message); } } public static void azzert(boolean expr, Throwable t) { if (!expr) { throw new AssertionError(t); } } }