System.Math.CompareValue
Delphi
function CompareValue(const A, B: Extended; Epsilon: Extended): TValueRelationship;
function CompareValue(const A, B: Double; Epsilon: Double): TValueRelationship;
function CompareValue(const A, B: Single; Epsilon: Single): TValueRelationship;
function CompareValue(const A, B: Integer): TValueRelationship;
function CompareValue(const A, B: Int64): TValueRelationship;
function CompareValue(const A, B: UInt64): TValueRelationship;
C++
extern DELPHI_PACKAGE System::Types::TValueRelationship __fastcall CompareValue(const System::Extended A, const System::Extended B, System::Extended Epsilon = 0.000000E+00)/* overload */;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | System.Math.pas System.Math.hpp |
System.Math | System.Math |
Description
Returns the relationship between two numeric values.
Call CompareValue to determine the relationship between two numeric values. When comparing floating-point values, CompareValue lets you specify a maximum difference to use when comparing values, so that they are considered the same if they are within that amount.
A
and B
are the values to compare.
Epsilon
is the maximum amount by which A
and B
can differ and still be considered the same value.
CompareValue returns one of the following constants defined for the TValueRelationship type:
LessThanValue
ifA
is less thanB
(by more thanEpsilon
ifA
andB
are floating-point numbers).EqualsValue
ifA
is equivalent toB
(the same, or withinEpsilon
ifA
andB
are floating-point numbers).GreaterThanValue
ifA
is larger thanB
(by more thanEpsilon
ifA
andB
are floating-point numbers).
If
, then some reasonable default value is used implicitly. For example, the Double version of SameValue uses the default value: Epsilon
= 0
Epsilon = Max(Min(Abs(A), Abs(B)) * 1E-12, 1E-12)