// (((Non in the valid range))) //[TestMethod] public void TwoProduct_ResultNonOverlapping() { double a = -1.4923680386317254E-201; string astr = a.ToFloatingPointBinaryString(); double b = -1.6707649245302712E-111; string bstr = b.ToFloatingPointBinaryString(); double x, y; EA.TwoProduct(a, b, out x, out y); string xstr = x.ToFloatingPointBinaryString(); string ystr = y.ToFloatingPointBinaryString(); var result = new[] { x, y }; // FAILS! But our input is not in the valid range according to S. p3 Assert.IsTrue(result.IsNonOverlapping()); }
// These are the conditions from S. Theorem 18 // multiplies and results in a nonoverlapping and nonadjacent expansion public static void TwoProduct_Checked(double a, double b, out double x, out double y) { EA.TwoProduct(a, b, out x, out y); // Don't check in case we'd overflow... if (!(2.0 * x).IsNumber() || !(2.0 * y).IsNumber()) return; var result = new[] { x, y }; Assert.IsTrue(result.IsNonOverlapping()); Assert.IsTrue(result.IsNonAdjacent()); Assert.AreEqual(a * b, x + y); }