if (right.sign != 0 && right.data.Length == 1 && right.data [0] == 1)
return new BigInteger (1, ONE);
if (left.IsZero)
- return right;
+ return Abs(right);
if (right.IsZero)
- return left;
+ return Abs(left);
BigInteger x = new BigInteger (1, left.data);
BigInteger y = new BigInteger (1, right.data);
+2013-06-12 Christoph Ruegg <git@cdrnet.ch>
+
+ * BigInteger.cs: Fix GreatestCommonDivisor to
+ return absolute value if one of the args is zero.
+
2013-06-09 Christoph Ruegg <git@cdrnet.ch>
* Complex.cs: Fix IFormattable.ToString to pass custom
Assert.AreEqual (2, (int)BigInteger.GreatestCommonDivisor (-12345678, -8765432), "#14");
Assert.AreEqual (40, (int)BigInteger.GreatestCommonDivisor (5581 * 40, 6671 * 40), "#15");
+
+ Assert.AreEqual (5, (int)BigInteger.GreatestCommonDivisor (-5, 0), "#16");
+ Assert.AreEqual (5, (int)BigInteger.GreatestCommonDivisor (0, -5), "#17");
}
[Test]
+2013-06-13 Christoph Ruegg <git@cdrnet.ch>
+
+ * BigIntegerTest.cs: Extended tests for
+ GreatestCommonDivisor to cover zero-args.
+
2013-06-09 Christoph Ruegg <git@cdrnet.ch>
* ComplexTest.cs: Created; Tests ToString