AdamWhiteHat/BigRational

BUG: Arithmetic bug with negative numbers

stewienj opened this issue · 1 comments

Description
There's an arithmetic bug with negative numbers, e.g. add -7 and -6 together and halve to find the mid point. I get -5.5, not the expected -6.5.

Steps To Reproduce

[TestMethod, TestCategory("Arithmetic")]
public void TestMidPoint()
{
	var low = (BigRational)(-7);
	var high = (BigRational)(-6);

	// Take the mid point of the above 2 numbers
	var mid = (low + high) / (BigRational)2;

	Assert.IsTrue(mid > low);
	Assert.IsTrue(mid < high);
}

Took me a while to realize I wasn't going crazy.

This should be fixed now..