Returns true if two values are equal to within a specified delta.

Namespace:  Gallio.Framework
Assembly:  Gallio (in Gallio.dll) Version: 3.3.0.0 (3.3.610.0)

Syntax

C#
public bool ApproximatelyEqual<TValue, TDifference>(
	TValue left,
	TValue right,
	TDifference delta
)
Visual Basic (Declaration)
Public Function ApproximatelyEqual(Of TValue, TDifference) ( _
	left As TValue, _
	right As TValue, _
	delta As TDifference _
) As Boolean

Parameters

left
Type: TValue
The expected value.
right
Type: TValue
The actual value.
delta
Type: TDifference
The inclusive delta between the values.

Type Parameters

TValue
The type of values to be compared.
TDifference
The type of the difference produced when the values are subtracted, for numeric types this is the same as TValue but it may differ for other types.

Return Value

True if the values are approximately equal.

Implements

IComparisonSemantics..::.ApproximatelyEqual<(Of <(TValue, TDifference>)>)(TValue, TValue, TDifference)

Remarks

The values are considered approximately equal if the absolute value of their difference is less than or equal to the delta.

This method works with any comparable type that also supports a subtraction operator including Single, Double, Decimal, Int32, DateTime (using a TimeSpan delta), and many others.

See Also