private void Normalize ()
{
// Normalize length
while (length > 0 && data [length-1] == 0) length--;
// Check for zero
if (length == 0)
length++;
}
public static BigInteger RightShift(BigInteger bi, int n) { if (n == 0) { return(new BigInteger(bi)); } int w = n >> 5; int s = n & ((1 << 5) - 1); BigInteger ret = new BigInteger(Sign.Positive, bi.length - (uint)w + 1); uint l = (uint)ret.data.Length - 1; if (s != 0) { uint x, carry = 0; while (l-- > 0) { x = bi.data[l + w]; ret.data[l] = (x >> n) | carry; carry = x << (32 - n); } } else { while (l-- > 0) { ret.data[l] = bi.data[l + w]; } } ret.Normalize(); return(ret); }