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

Namespace: Extreme.Mathematics
Assembly: Extreme.Numerics (Extreme.Numerics)

Syntax

Visual Basic (Declaration)
Public Class DoubleComparer _
	Implements IComparer, IComparer(Of Double)
C#
public class DoubleComparer : IComparer, IComparer<double>
C++
public ref class DoubleComparer : IComparer, IComparer<double>

Methods

IconTypeDescription
Compare(Double, Double)
Compares two Double values and returns a value indicating whether one is less than, equal to or greater than the other.
Equals(Object)
Determines whether the specified Object is equal to the current Object.
Finalize()
Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
GetHashCode()
Serves as a hash function for a particular type.
GetType()
Gets the Type of the current instance.
MemberwiseClone()
Creates a shallow copy of the current Object.
ToString()
Returns a String that represents the current Object.

Constructors

IconTypeDescription
DoubleComparerNew(Double)
Initializes a new instance of the DoubleComparer class.

Properties

IconTypeDescription
Tolerance
Gets or sets the relative tolerance within which two numbers compare equal.

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.

Inheritance Hierarchy

System.Object
  Extreme.Mathematics.DoubleComparer