Click or drag to resize

SetFloatDelta Function (Double)

Return and optionally change the setting that determines the point at which 2 floating point numbers would be considered equal even though they are different.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.3
Syntax
 FUNCTION SetFloatDelta(
	nNewSetting AS REAL8
) AS REAL8
View Source

Parameters

nNewSetting
Type: Double
The acceptable difference between 2 numbers.

Return Value

Type: Double
If <nNewSetting> is not specified, SetFloatDelta() returns the current setting.  If <nNewSetting> is specified, the previous setting is returned.
Remarks
SetFloatDelta() determines the maximum amount by which 2 floating point numbers could be different and yet still be considered equal.  Two numbers might be considerably different, but the difference will be ignored if the setting for SetFloatDelta() is larger than the difference between the 2 numbers.
Examples
This example uses SetFloatDelta() to change the result of numeric comparisons:
X#
1? 1.231 =  1.23                    // FALSE
2? 1.33 = 1.23                    // FALSE
3SetFloatDelta(0.01)                // Delta at 0.01
4? 1.231 = 1.23                    // TRUE since 1.231-1.23 < 0.01
5? 1.33 = 1.23                    // FALSE since 1.33-1.23 > 0.01
6? 1.4 < 1.40123456                // FALSE
7? 1.4 < 1.42                    // TRUE
See Also