Compare.AlmostEqualsAbsolute Method

Definition

Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.6

Overload List

AlmostEqualsAbsolute<T>(T, T, Boolean, Boolean) Returns whether the specified value is close to the reference value within the default absolute tolerance.
AlmostEqualsAbsolute<T>(T, T, T, Boolean, Boolean) Returns whether the specified value is close to the reference value within the given absolute tolerance.

AlmostEqualsAbsolute<T>(T, T, Boolean, Boolean)

Returns whether the specified value is close to the reference value within the default absolute tolerance.
C#
public static bool AlmostEqualsAbsolute<T>(
	this T value1,
	T value2,
	bool equalNaN = false,
	bool equalInfinity = true
)
where T : Object, IComparable<T>

Parameters

value1  T
The value to compare.
value2  T
The reference value to compare against.
equalNaN  Boolean  (Optional)
Optional. Specifies whether NaN values are considered equal. The default is false.
equalInfinity  Boolean  (Optional)
Optional. Specifies whether infinite values with the same sign are considered equal. The default is true.

Type Parameters

T
The type of the values to compare.

Return Value

Boolean
true if the values are close; otherwise, false.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type T. 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).

Remarks

Absolute comparisons are always symmetric.

AlmostEqualsAbsolute<T>(T, T, T, Boolean, Boolean)

Returns whether the specified value is close to the reference value within the given absolute tolerance.
C#
public static bool AlmostEqualsAbsolute<T>(
	this T value1,
	T value2,
	T absoluteTolerance,
	bool equalNaN = false,
	bool equalInfinity = true
)
where T : Object, IComparable<T>

Parameters

value1  T
The value to compare.
value2  T
The reference value to compare against.
absoluteTolerance  T
Optional. The absolute tolerance.
equalNaN  Boolean  (Optional)
Optional. Specifies whether NaN values are considered equal. The default is false.
equalInfinity  Boolean  (Optional)
Optional. Specifies whether infinite values with the same sign are considered equal. The default is true.

Type Parameters

T
The type of the values to compare.

Return Value

Boolean
true if the values are close; otherwise, false.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type T. 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).

Remarks

Absolute comparisons are always symmetric.

See Also