private NetBigInteger AddToMagnitude(
int[] magToAdd)
{
int[] big, small;
if (m_magnitude.Length < magToAdd.Length)
{
big = magToAdd;
small = m_magnitude;
}
else
{
big = m_magnitude;
small = magToAdd;
}
// Conservatively avoid over-allocation when no overflow possible
uint limit = uint.MaxValue;
if (big.Length == small.Length)
limit -= (uint)small[0];
bool possibleOverflow = (uint)big[0] >= limit;
int[] bigCopy;
if (possibleOverflow)
{
bigCopy = new int[big.Length + 1];
big.CopyTo(bigCopy, 1);
}
else
{
bigCopy = (int[])big.Clone();
}
bigCopy = AddMagnitudes(bigCopy, small);
return new NetBigInteger(m_sign, bigCopy, possibleOverflow);
}