Here you can find the source of mod(int num, int div)
Parameter | Description |
---|---|
num | Input number |
div | Divisor for modulus |
public static int mod(int num, int div)
//package com.java2s; //License from project: Open Source License public class Main { /**// ww w. j ava2s. c o m * Returns the modulus of the input value (taking care of the sign of the value) * * @param num Input number * @param div Divisor for modulus * @return Modulus of num by div */ public static int mod(int num, int div) { if (num < 0) { return div - (-num % div); } else { return num % div; } } }