Click or drag to resize
DigitalRuneNumeric Class
Provides methods for robust floating-point comparisons (for float and double).
Inheritance Hierarchy
SystemObject
  DigitalRune.MathematicsNumeric

Namespace: DigitalRune.Mathematics
Assembly: DigitalRune (in DigitalRune.dll) Version: 1.20.0.0 (1.20.1.14552)
Syntax
public static class Numeric

The Numeric type exposes the following members.

Methods
  NameDescription
Public methodStatic memberAreEqual(Double, Double)
Determines whether two values are equal (regarding the tolerance EpsilonD).
Public methodStatic memberAreEqual(Single, Single)
Determines whether two values are equal (regarding the tolerance EpsilonF).
Public methodStatic memberAreEqual(Double, Double, Double)
Determines whether two values are equal (regarding a specific tolerance).
Public methodStatic memberAreEqual(Single, Single, Single)
Determines whether two values are equal (regarding a specific tolerance).
Public methodStatic memberClampToZero(Double)
Clamps near-zero values to zero.
Public methodStatic memberClampToZero(Single)
Clamps near-zero values to zero.
Public methodStatic memberClampToZero(Double, Double)
Clamps near-zero values to zero.
Public methodStatic memberClampToZero(Single, Single)
Clamps near-zero values to zero.
Public methodStatic memberCompare(Double, Double)
Compares two double values (regarding the tolerance EpsilonD).
Public methodStatic memberCompare(Single, Single)
Compares two float values (regarding the tolerance EpsilonF).
Public methodStatic memberCompare(Double, Double, Double)
Compares two double values (regarding a specific tolerance).
Public methodStatic memberCompare(Single, Single, Single)
Compares two float values (regarding a specific tolerance).
Public methodStatic memberGetSignificantBitsSigned
Gets the significant bits of a floating-point number, which can be used for rough comparisons or sorting. (The floating-point number can negative or positive.)
Public methodStatic memberGetSignificantBitsUnsigned
Gets the significant bits of a floating-point number, which can be used for rough comparisons or sorting. (The floating-point number must be positive.)
Public methodStatic memberIsFinite(Double)
Determines whether the specified value is finite.
Public methodStatic memberIsFinite(Single)
Determines whether the specified value is finite.
Public methodStatic memberIsFiniteOrNaN(Double)
Determines whether the specified value is finite or NaN.
Public methodStatic memberIsFiniteOrNaN(Single)
Determines whether the specified value is finite or NaN.
Public methodStatic memberIsGreater(Double, Double)
Determines whether a value is greater than another value (regarding the tolerance EpsilonD).
Public methodStatic memberIsGreater(Single, Single)
Determines whether a value is greater than another value (regarding the tolerance EpsilonF).
Public methodStatic memberIsGreater(Double, Double, Double)
Determines whether a value is greater than another value (regarding the specified tolerance).
Public methodStatic memberIsGreater(Single, Single, Single)
Determines whether a value is greater than another value (regarding the specified tolerance).
Public methodStatic memberIsGreaterOrEqual(Double, Double)
Determines whether a value is greater than or equal to another value (regarding the tolerance EpsilonD).
Public methodStatic memberIsGreaterOrEqual(Single, Single)
Determines whether a value is greater than or equal to another value (regarding the tolerance EpsilonF).
Public methodStatic memberIsGreaterOrEqual(Double, Double, Double)
Determines whether a value is greater than or equal to another value (regarding the specified tolerance).
Public methodStatic memberIsGreaterOrEqual(Single, Single, Single)
Determines whether a value is greater than or equal to another value (regarding the specified tolerance).
Public methodStatic memberIsLess(Double, Double)
Determines whether a value is less than another value (regarding the tolerance EpsilonD).
Public methodStatic memberIsLess(Single, Single)
Determines whether a value is less than another value (regarding the tolerance EpsilonF).
Public methodStatic memberIsLess(Double, Double, Double)
Determines whether a value is less than another value (regarding the specified tolerance).
Public methodStatic memberIsLess(Single, Single, Single)
Determines whether a value is less than another value (regarding the specified tolerance).
Public methodStatic memberIsLessOrEqual(Double, Double)
Determines whether a value is less than or equal to another value (regarding the tolerance EpsilonD).
Public methodStatic memberIsLessOrEqual(Single, Single)
Determines whether a value is less than or equal to another value (regarding the tolerance EpsilonF).
Public methodStatic memberIsLessOrEqual(Double, Double, Double)
Determines whether a value is less than or equal to another value (regarding the specified tolerance).
Public methodStatic memberIsLessOrEqual(Single, Single, Single)
Determines whether a value is less than or equal to another value (regarding the specified tolerance).
Public methodStatic memberIsNaN(Double)
Returns a value indicating whether the specified number is NaN.
Public methodStatic memberIsNaN(Single)
Returns a value indicating whether the specified number is NaN.
Public methodStatic memberIsNegative(Double)
Determines whether the specified value is negative.
Public methodStatic memberIsNegative(Single)
Determines whether the specified value is negative.
Public methodStatic memberIsNegativeFinite(Double)
Determines whether the specified value is negative finite.
Public methodStatic memberIsNegativeFinite(Single)
Determines whether the specified value is negative finite.
Public methodStatic memberIsPositive(Double)
Determines whether the specified value is positive.
Public methodStatic memberIsPositive(Single)
Determines whether the specified value is positive.
Public methodStatic memberIsPositiveFinite(Double)
Determines whether the specified value is positive finite.
Public methodStatic memberIsPositiveFinite(Single)
Determines whether the specified value is positive finite.
Public methodStatic memberIsZero(Double)
Determines whether a value is zero (regarding the tolerance EpsilonD).
Public methodStatic memberIsZero(Single)
Determines whether a value is zero (regarding the tolerance EpsilonF).
Public methodStatic memberIsZero(Double, Double)
Determines whether a value is zero (regarding a specific tolerance).
Public methodStatic memberIsZero(Single, Single)
Determines whether a value is zero (regarding a specific tolerance).
Public methodStatic memberIsZeroOrNegativeFinite(Double)
Determines whether the specified value is 0 or negative finite.
Public methodStatic memberIsZeroOrNegativeFinite(Single)
Determines whether the specified value is 0 or negative finite.
Public methodStatic memberIsZeroOrPositiveFinite(Double)
Determines whether the specified value is 0 or positive finite.
Public methodStatic memberIsZeroOrPositiveFinite(Single)
Determines whether the specified value is 0 or positive finite.
Top
Properties
  NameDescription
Public propertyStatic memberEpsilonD
Gets or sets the tolerance value used for comparison of double values.
Public propertyStatic memberEpsilonDSquared
Gets the squared tolerance value used for comparison of double values. (EpsilonD * EpsilonD).
Public propertyStatic memberEpsilonF
Gets or sets the tolerance value used for comparison of float values.
Public propertyStatic memberEpsilonFSquared
Gets the squared tolerance value used for comparison of float values. (EpsilonF * EpsilonF).
Top
Remarks

Floating-point values are difficult to compare for equality because of numerical errors. This class provides methods to compare floating-point values with regard to numerical errors.

To compare floating-point values a tolerance value epsilon will be used. Values smaller than the epsilon tolerance are treated as equal to 0. Floating-point values are considered equal when the difference is less than the epsilon tolerance.

Some methods allow to use a custom epsilon. If the method has no epsilon parameter, then the default values EpsilonF (for float) or EpsilonD (for double) are used.

Note that when two large floating-point numbers need to be compared a bigger epsilon tolerance needs to be used than when comparing a floating-point number with zero. When comparing two floating-point numbers using the default epsilon tolerance EpsilonF or EpsilonD (see AreEqual(Single, Single) or AreEqual(Double, Double)) then the epsilon values are automatically scaled to match the range and resolution of the floating-point numbers. When two floating-point numbers are compared using an explicit epsilon value (see AreEqual(Single, Single, Single) or AreEqual(Double, Double, Double)) then this epsilon value is used directly.

See Also