When comparing vary large doubles it happens that the following test fails:
[Test]
public void DoubleMaxValueTest()
{
double val = Double.MaxValue;
double epsilon = 10000.0;
Assert.IsTrue(val > (Double.MaxValue - epsilon));
}
Being aware that doubles are represented as mantissa, exponent and a sign bit it is due to the fact that the value Double.MaxValue - 10000 is actually represented the same way as Double.MaxValue (these values are equal).
The question is: How to get the smallest epsilon for which this test returns true?