Microsoft.Scripting.Utils.MathUtils.FloorDivideUnchecked C# (CSharp) Method

FloorDivideUnchecked() public static method

Calculates the quotient of two 32-bit signed integers rounded towards negative infinity.
The caller must check for overflow (x = Int32.MinValue, y = -1)
is 0.
public static FloorDivideUnchecked ( int x, int y ) : int
x int Dividend.
y int Divisor.
return int
        public static int FloorDivideUnchecked(int x, int y) {
            int q = x / y;

            if (x >= 0) {
                if (y > 0) {
                    return q;
                } else if (x % y == 0) {
                    return q;
                } else {
                    return q - 1;
                }
            } else {
                if (y > 0) {
                    if (x % y == 0) {
                        return q;
                    } else {
                        return q - 1;
                    }
                } else {
                    return q;
                }
            }
        }

Same methods

MathUtils::FloorDivideUnchecked ( long x, long y ) : long