Represents a comparer for double-precision
floating-point numbers with specified tolerance.
SystemObject Extreme.MathematicsDoubleComparer
Namespace:
Extreme.Mathematics
Assembly:
Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.1
public class DoubleComparer : IComparer,
IComparer<double>
Public Class DoubleComparer
Implements IComparer, IComparer(Of Double)
public ref class DoubleComparer : IComparer,
IComparer<double>
type DoubleComparer =
class
interface IComparer
interface IComparer<float>
end
The DoubleComparer type exposes the following members.
| Name | Description |
---|
 | DoubleComparer |
Initializes a new instance of the
DoubleComparer class.
|
Top
| Name | Description |
---|
 | Tolerance |
Gets or sets the relative tolerance within which
two numbers compare equal.
|
Top
| Name | Description |
---|
 | Compare |
Compares two Double values and returns
a value indicating whether one is less than, equal to or greater than the other.
|
 | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
 | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
 | GetHashCode | Serves as the default hash function. (Inherited from Object.) |
 | GetType | Gets the Type of the current instance. (Inherited from Object.) |
 | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
 | ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
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.
Reference