RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Math.CompareValue Function

Returns the relationship between two numeric values.

Pascal
function CompareValue(const A: Extended; const B: Extended; Epsilon: Extended = 0): TValueRelationship; overload;
function CompareValue(const A: Double; const B: Double; Epsilon: Double = 0): TValueRelationship; overload;
function CompareValue(const A: Single; const B: Single; Epsilon: Single = 0): TValueRelationship; overload;
function CompareValue(const A: Integer; const B: Integer): TValueRelationship; overload;
function CompareValue(const A: Int64; const B: Int64): TValueRelationship; overload;
C++
TValueRelationship CompareValue(const Extended A, const Extended B, Extended Epsilon = 0);
TValueRelationship CompareValue(const Double A, const Double B, Double Epsilon = 0);
TValueRelationship CompareValue(const Single A, const Single B, Single Epsilon = 0);
TValueRelationship CompareValue(const int A, const int B);
TValueRelationship CompareValue(const Int64 A, const Int64 B);

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  

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). 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!