Home > Extreme Optimization Mathematics Library for .NET > Reference > Extreme.Mathematics Namespace


Extreme Optimization Mathematics Library for .NET

DoubleComparer Class

Represents a comparer for double-precision floating-point numbers with specified tolerance.

For a list of all members of this type, see DoubleComparer Members.

System.Object
   DoubleComparer

[Visual Basic]
Public Class DoubleComparer
Implements IComparer
[C#]
public class DoubleComparer : IComparer

Remarks

Two apparently equivalent floating-point numbers may not compare equal because of differences in their least significant digits. This is usually caused by round-off error resulting from the finite precision of floating-point representations. For example, the C# expression, (double)1/3 == (double)0.33333, does not compare equal because the division operation on the left-hand side has maximum precision while the constant on the right-hand side is only precise to the visible digits.

Instead, determine if the two sides of a comparison are close enough to equal for your purposes. The DoubleComparer class lets you specify the tolerance within which two numbers are considered equal.

Requirements

Namespace: Extreme.Mathematics

Assembly: Extreme.Mathematics (in Extreme.Mathematics.dll)

See Also

DoubleComparer Members | Extreme.Mathematics Namespace