Java floor floorDivide(long n, long d)

Here you can find the source of floorDivide(long n, long d)

Description

floor Divide

License

Mozilla Public License

Declaration

public static final long floorDivide(long n, long d) 

Method Source Code

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

public class Main {
    public static final long floorDivide(long n, long d) {
        return ((n >= 0) ? (n / d) : (((n + 1L) / d) - 1L));
    }//from   w w  w . j a v a  2s .  com

    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. floorDiv(int dividend, int divisor)
  2. floorDiv(int v1, int v2)
  3. floorDiv(long a, long b)
  4. floorDiv(long x, long y)
  5. floorDivide(int value, int divisor)
  6. floorDivide(long numerator, long denominator)
  7. floorDivision(int i, int divisor)
  8. floorHalf(int num)
  9. floorInt(Double d, double intv)