Click or drag to resize

PrecisionAlmostEqualNumbersBetween(Double, Double, Int64) Method

Compares two doubles and determines if they are equal to within the tolerance or not. Equality comparison is based on the binary representation.

Namespace: Altaxo.Calc
Assembly: AltaxoCore (in AltaxoCore.dll) Version: 4.8.3179.0 (4.8.3179.0)
Syntax
C#
public static bool AlmostEqualNumbersBetween(
	this double a,
	double b,
	long maxNumbersBetween
)

Parameters

a  Double
The first value.
b  Double
The second value.
maxNumbersBetween  Int64
The maximum number of floating point values between the two values. Must be 1 or larger.

Return Value

Boolean

[Missing <returns> documentation for "M:Altaxo.Calc.Precision.AlmostEqualNumbersBetween(System.Double,System.Double,System.Int64)"]

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Double. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions
ExceptionCondition
ArgumentOutOfRangeExceptionThrown if maxNumbersBetween is smaller than one.
Remarks

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.

See Also