public NetBigInteger Divide(
NetBigInteger val)
{
if (val.m_sign == 0)
throw new ArithmeticException("Division by zero error");
if (m_sign == 0)
return Zero;
if (val.QuickPow2Check()) // val is power of two
{
NetBigInteger result = Abs().ShiftRight(val.Abs().BitLength - 1);
return val.m_sign == m_sign ? result : result.Negate();
}
int[] mag = (int[])m_magnitude.Clone();
return new NetBigInteger(m_sign * val.m_sign, Divide(mag, val.m_magnitude), true);
}