public void MirroredFloatReinterpretation() { Assert.AreEqual( 12345, FloatingPointNumerics.ReinterpretAsInt( FloatingPointNumerics.ReinterpretAsFloat(12345) ) ); }
public void MirroredLongReinterpretation() { Assert.AreEqual( 12345.67890, FloatingPointNumerics.ReinterpretAsDouble( FloatingPointNumerics.ReinterpretAsLong(12345.67890) ) ); }
public void DoubleEqualityWithUlps() { Assert.IsTrue( FloatingPointNumerics.AreAlmostEqualUlps(0.00000001, 0.000000010000000000000002, 1) ); Assert.IsFalse( FloatingPointNumerics.AreAlmostEqualUlps(0.00000001, 0.000000010000000000000004, 1) ); Assert.IsTrue( FloatingPointNumerics.AreAlmostEqualUlps(1000000.00, 1000000.0000000001, 1) ); Assert.IsFalse( FloatingPointNumerics.AreAlmostEqualUlps(1000000.00, 1000000.0000000002, 1) ); }
public void FloatEqualityWithUlps() { Assert.IsTrue( FloatingPointNumerics.AreAlmostEqualUlps(0.00000001f, 0.0000000100000008f, 1) ); Assert.IsFalse( FloatingPointNumerics.AreAlmostEqualUlps(0.00000001f, 0.0000000100000017f, 1) ); Assert.IsTrue( FloatingPointNumerics.AreAlmostEqualUlps(1000000.00f, 1000000.06f, 1) ); Assert.IsFalse( FloatingPointNumerics.AreAlmostEqualUlps(1000000.00f, 1000000.13f, 1) ); }