Java Integer Mod mod(int x, int y)

Here you can find the source of mod(int x, int y)

Description

Perform (x mod y).

License

Open Source License

Return

x mod y

Declaration

private static int mod(int x, int y) 

Method Source Code

//package com.java2s;
/*/*from ww w.j  a v  a 2 s . c o  m*/
 * Copyright (C) 2012  George Parisis 
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version
 * 2 as published by the Free Software Foundation.
 *
 * Alternatively, this software may be distributed under the terms of
 * the BSD license.
 *
 * See LICENSE and COPYING for more details.
 */

public class Main {
    /**
     * Perform (x mod y).  This is necessary because the java % operator
     * is actually remainder instead of mod.  Useless.
     *
     * @return x mod y
     */
    private static int mod(int x, int y) {
        if ((x < 0) ^ (y < 0)) {
            return y + (x % y);

        } else {
            return x % y;

        }
    }
}

Related

  1. mod(int hash, int size)
  2. mod(int i, int n)
  3. mod(int num, int div)
  4. mod(int v, int m)
  5. mod(int x, int y)
  6. mod(int x, int y)
  7. mod(int[]... vectors)
  8. mod(long l, int m)
  9. mod4(int a)