Java Long Number Mod mod(long x, long y)

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

Description

mod

License

Mozilla Public License

Declaration

public static final long mod(long x, long y) 

Method Source Code

//package com.java2s;
//License from project: Mozilla Public License 

public class Main {
    public static final long mod(long x, long y) {
        return (x - y * floorDivide(x, y));
    }//from w  w w  . java 2  s .c om

    public static final int mod(int x, int y) {
        return (x - y * floorDivide(x, y));
    }

    public static final long floorDivide(long n, long d) {
        return ((n >= 0) ? (n / d) : (((n + 1L) / d) - 1L));
    }

    public static final int floorDivide(int n, int d) {
        return ((n >= 0) ? (n / d) : (((n + 1) / d) - 1));
    }

    public static final int floorDivide(int n, int d, int[] r) {
        if (n >= 0) {
            r[0] = n % d;
            return n / d;
        }
        int q = ((n + 1) / d) - 1;
        r[0] = n - (q * d);
        return q;
    }

    public static final int floorDivide(long n, int d, int[] r) {
        if (n >= 0) {
            r[0] = (int) (n % d);
            return (int) (n / d);
        }
        int q = (int) (((n + 1) / d) - 1);
        r[0] = (int) (n - (q * d));
        return q;
    }
}

Related

  1. mod(long a, long b)
  2. mod(long pNum, long pDivisor)
  3. mod(long v, long m)
  4. modDivide(long a, long b, long m)
  5. modifiedCalcElementOffset(long index, long mask)
  6. modifyValue(long value, char op, long modifier, long max, long min)
  7. mods(long v, long m)