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 if A is less than B (by more than Epsilon if A and B are floating-point numbers).
• EqualsValue if A is equivalent to B (the same, or within Epsilon if A and B are floating-point numbers).
• GreaterThanValue if A is larger than B (by more than Epsilon if A and B are floating-point numbers).

If Epsilon = 0, then some reasonable default value is used implicitly. For example, the Double version of SameValue uses the default value:

Epsilon = Max(Min(Abs(A), Abs(B)) * 1E-12, 1E-12)