public static int Compare(BigInteger x, BigInteger y) {
if (object.ReferenceEquals(x, null)) {
throw new ArgumentNullException("x");
}
if (object.ReferenceEquals(y, null)) {
throw new ArgumentNullException("y");
}
if (x.sign == y.sign) {
int xl = x.Length;
int yl = y.Length;
if (xl == yl) {
for (int i = xl - 1; i >= 0; i--) {
if (x.data[i] == y.data[i]) continue;
return x.data[i] > y.data[i] ? x.sign : -x.sign;
}
return 0;
} else {
return xl > yl ? +x.sign : -x.sign;
}
} else {
return x.sign > y.sign ? +1 : -1;
}
}