double temp1 = 0.1 - 0.025;
((object)temp1).Should().BeEquivalentTo(temp2, options => options.Using<double>(a => a.Subject.HasMinimalDifference(a.Expectation, 1)).WhenTypeIs<double>());
Console.WriteLine("passed\n-----");
((object)temp1).Should().BeEquivalentTo(10, options => options.Using<double>(a => a.Subject.HasMinimalDifference(a.Expectation, 1)).WhenTypeIs<double>());
public static class DoubleExts
public static bool HasMinimalDifference(this double value1, double value2, int units)
long lValue1 = BitConverter.DoubleToInt64Bits(value1);
long lValue2 = BitConverter.DoubleToInt64Bits(value2);
if ((lValue1 >> 63) != (lValue2 >> 63))
long diff = Math.Abs(lValue1 - lValue2);