1
Vote

bool operator >(BigInteger bi1, BigInteger bi2) returns incorrect value

description

The following unit test fails:
BigInteger cost = 10;
BigInteger money = new BigInteger(1, 160);
Assert.AreEqual(false, cost > money);
Result:
Test Name:  inequalityTest
Test FullName:  Tests.BigIntegerTests.inequalityTest
Test Source:    draco18s\util\BigIntegerTests.cs : line 30
Test Outcome:   Failed
Test Duration:  0:00:00.0195049

Result StackTrace:  at BigIntegerTests.inequalityTest() in draco18s\util\BigIntegerTests.cs:line 45
Result Message: Assert.AreEqual failed. Expected:<False>. Actual:<True>.
Note that I have added a new constructor to create values in Engineering notation (in this case, 1e160) as follows:
public BigInteger(long mantissa, long exponent):this(mantissa) {
    for(int p = 1; p <= exponent; p++) {
        this *= 10;
    }
}
I corrected this by making it return the inverted result of <

comments