Compare.AlmostEqualsRelative Method

Definition

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

Overload List

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

AlmostEqualsRelative<T>(T, T, Boolean, Boolean, Boolean)

Returns whether the specified value is close to the reference value within the default relative tolerance.
C#
public static bool AlmostEqualsRelative<T>(
	this T value1,
	T value2,
	bool equalNaN = false,
	bool equalInfinity = true,
	bool symmetric = false
)
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.
symmetric  Boolean  (Optional)
Optional. If false (the default), value2 is used as the reference value. If true, the value with the largest magnitude is used as the reference value.

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).

AlmostEqualsRelative<T>(T, T, T, Boolean, Boolean, Boolean)

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

Parameters

value1  T
The value to compare.
value2  T
The reference value to compare against.
relativeTolerance  T
Optional. The relative 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.
symmetric  Boolean  (Optional)
Optional. If false (the default), value2 is used as the reference value. If true, the value with the largest magnitude is used as the reference value.

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).

See Also