Here you can find the source of modulo(int a, int b)
protected static int modulo(int a, int b)
//package com.java2s; /******************************************************************************* * Copyright (c) 2005, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w ww. j a va2 s. c om * IBM Corporation - initial API and implementation *******************************************************************************/ public class Main { protected static int modulo(int a, int b) { return a - fQuotient(a, b) * b; } protected static int fQuotient(int a, int b) { return (int) Math.floor((double) a / (double) b); } }