Table of Contents

Method AreCloseScaled

Namespace
Alternet.UI
Assembly
Alternet.UI.Common.dll

AreCloseScaled(double, double)

Returns true if the two doubles are close enough to be considered equal. Handles infinities and near-zero values.

public static bool AreCloseScaled(double value1, double value2)

Parameters

value1 double
value2 double

Returns

bool
See Also

AreCloseScaled(float, float)

Returns true if the two single-precision floats are close enough to be considered equal. Handles infinities and near-zero values using scaled epsilon.

public static bool AreCloseScaled(float value1, float value2)

Parameters

value1 float

First value to compare.

value2 float

Second value to compare.

Returns

bool

true if the values are close; otherwise, false.

Examples

AreCloseScaled(1.0f, 1.000001f)     // true
AreCloseScaled(0.0f, 1e-8f)         // false
AreCloseScaled(float.NaN, float.NaN) // false
AreCloseScaled(float.PositiveInfinity, float.PositiveInfinity) // true

Remarks

This method scales the epsilon based on the magnitude of the inputs, ensuring robustness near zero and across large ranges.