PrecisionAlmost |
public static bool AlmostEqualNumbersBetween( this double a, double b, long maxNumbersBetween )
[Missing <returns> documentation for "M:Altaxo.Calc.Precision.AlmostEqualNumbersBetween(System.Double,System.Double,System.Int64)"]
Exception | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if maxNumbersBetween is smaller than one. |
Determines the 'number' of floating point numbers between two values (i.e. the number of discrete steps between the two numbers) and then checks if that is within the specified tolerance. So if a tolerance of 1 is passed then the result will be true only if the two numbers have the same binary representation OR if they are two adjacent numbers that only differ by one step.
The comparison method used is explained in http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm . The article at http://www.extremeoptimization.com/resources/Articles/FPDotNetConceptsAndFormats.aspx explains how to transform the C code to .NET enabled code without using pointers and unsafe code.