Click or drag to resize

PrecisionAlmostEqualNormRelative(Double, Double, Double, Int32) Method

Compares two doubles and determines if they are equal to within the specified number of decimal places or not. If the numbers are very close to zero an absolute difference is compared, otherwise the relative difference is compared.

Namespace: Altaxo.Calc
Assembly: AltaxoCore (in AltaxoCore.dll) Version: 4.8.3179.0 (4.8.3179.0)
Syntax
C#
public static bool AlmostEqualNormRelative(
	this double a,
	double b,
	double diff,
	int decimalPlaces
)

Parameters

a  Double
The norm of the first value (can be negative).
b  Double
The norm of the second value (can be negative).
diff  Double
The norm of the difference of the two values (can be negative).
decimalPlaces  Int32
The number of decimal places.

Return Value

Boolean

[Missing <returns> documentation for "M:Altaxo.Calc.Precision.AlmostEqualNormRelative(System.Double,System.Double,System.Double,System.Int32)"]

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Double. 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).
Exceptions
ExceptionCondition
ArgumentOutOfRangeExceptionThrown if decimalPlaces is smaller than zero.
Remarks

The values are equal if the difference between the two numbers is smaller than 10^(-numberOfDecimalPlaces). We divide by two so that we have half the range on each side of the numbers, e.g. if decimalPlaces == 2, then 0.01 will equal between 0.005 and 0.015, but not 0.02 and not 0.00

See Also