public static Int64 Divide(Int64 dividend, Int64 divisor, out Int64 remainder) { UInt64 dend, dor; UInt64 r; dend = Abs(dividend); dor = Abs(divisor); UInt64 q = UInt64.Divide(dend, dor, out r); /* the sign of the remainder is the same as the sign of the dividend * and the quotient is negated if the signs of the operands are * opposite */ Int64 quotient = new Int64(q); remainder = new Int64(r); if (dividend < 0) { remainder = -remainder; if (divisor > 0) { quotient = -quotient; } } else { /* positive dividend */ if (divisor < 0) { quotient = -quotient; } } return(quotient); }
public void TestMisc() { var v = UInt64.Divide(new UInt64(11u), new UInt64(10u)); AreEquals(1UL, v); }