Java Integer Mod modulo(int dividend, int divisor)

Here you can find the source of modulo(int dividend, int divisor)

Description

Modulo Fix for negative numbers

License

Open Source License

Parameter

Parameter Description
dividend the number that is being divided by. Appears on Left
divisor the number the dividend is being divided by. Appears on Right

Declaration

public static int modulo(int dividend, int divisor) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from  w w w .j a  v a  2 s  . c om
     * Modulo Fix for negative numbers
     *
     * @param dividend the number that is being divided by. Appears on Left
     * @param divisor the number the dividend is being divided by. Appears on
     * Right
     * @return
     */
    public static int modulo(int dividend, int divisor) {
        return (dividend % divisor + divisor) % divisor;
    }
}

Related

  1. modularInverses(int p)
  2. modularInvert(int num, int modulus)
  3. modulateCircularIndex(int index, int seqLength)
  4. modulo(int a, int b)
  5. modulo(int a, int b)
  6. modulo(int x, int m)
  7. modulo(int x, int mod)
  8. modulo(int x, int y)
  9. moduloPositive(final int value, final int size)