Compare.AlmostEqualsUlps<T> Method

Returns whether the specified value is close to the reference value within the given tolerance expressed in ULPs (units in the last place).

DefinitionPermalink

Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.7
C#
public static bool AlmostEqualsUlps<T>(
	this T value1,
	T value2,
	T ulps,
	bool equalNaN = false,
	bool equalInfinity = true,
	bool symmetric = false
)
where T : Object, IComparable<T>

ParametersPermalink

value1  T
The value to compare.
value2  T
The reference value to compare against.
ulps  T
Optional. The tolerance in ULPs (units in the last place).
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 ParametersPermalink

T
The type of the values to compare.

Return ValuePermalink

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

Usage NotePermalink

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 AlsoPermalink