Java Integer Mod mod(int a, int b)

Here you can find the source of mod(int a, int b)

Description

Utility which does *proper* modding, where the result is guaranteed to be positive.

License

Open Source License

Parameter

Parameter Description
a The modee
b The value to mod by

Return

The result

Declaration

public static int mod(int a, int b) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from w  w  w . j a v a  2s .c  om*/
     * Utility which does *proper* modding, where the result is guaranteed to be
     * positive.
     *
     * @param a The modee
     * @param b The value to mod by
     * @return The result
     */
    public static int mod(int a, int b) {
        return ((a % b) + b) % b;
    }
}

Related

  1. mod(final int dividend, final int divisor)
  2. mod(final int n, final int N)
  3. mod(int a, int b)
  4. Mod(int a, int b)
  5. mod(int a, int b)
  6. mod(int a, int n)
  7. mod(int a, int n)
  8. mod(int divisor, int dividend)
  9. mod(int hash, int size)