public static void TestDoubleRounding( EFloat expected, EFloat input, EFloat src) { if (!input.IsFinite || !expected.IsFinite) { return; } double expectedDouble = expected.ToDouble(); if (Double.IsInfinity(expectedDouble)) { return; } string str = input.ToString(); if (input.ToDouble() != expectedDouble) { string msg = "\nexpectedDbl " + OutputDouble(expectedDouble) + ",\ngot----- " + OutputDouble(input.ToDouble()) + "\nsrc-----=" + OutputEF(src) + "\nexpected=" + OutputEF(expected) + "\ninput---=" + OutputEF(input); Assert.Fail(msg); } double inputDouble = EDecimal.FromString(str).ToDouble(); if (inputDouble != expectedDouble) { string msg = "\nexpectedDbl " + OutputDouble(expectedDouble) + ",\ngot----- " + OutputDouble(inputDouble) + "\nsrc-----=" + OutputEF(src) + "\nexpected=" + OutputEF(expected) + "\ninput---=" + OutputEF(input); Assert.Fail(msg); } }
public static string OutputEF(EFloat ef) { return ef.ToDouble() + " [" + ef.Mantissa.Abs().ToRadixString(2) + "," + ef.Exponent + "]"; }