1
0
mirror of synced 2024-11-09 21:09:16 +00:00

Added: CompareFloat

This commit is contained in:
Mark van Renswoude 2004-11-02 12:59:27 +00:00
parent bc8f3cd7d6
commit 9f2bf5aa94

View File

@ -30,6 +30,16 @@ interface
//:: -1 when Value1 is less than Value2. //:: -1 when Value1 is less than Value2.
function CompareInt(const AValue1, AValue2: Int64): Integer; overload; function CompareInt(const AValue1, AValue2: Int64): Integer; overload;
//:$ Compares two floating point values
//:: Returns 0 if the values are equal, 1 if Value1 is greater than Value2 and
//:: -1 when Value1 is less than Value2.
function CompareFloat(const AValue1, AValue2: Single): Integer; overload;
//:$ Compares two floating point values
//:: Returns 0 if the values are equal, 1 if Value1 is greater than Value2 and
//:: -1 when Value1 is less than Value2.
function CompareFloat(const AValue1, AValue2: Double): Integer; overload;
//:$ Checks if the value is within the specified range //:$ Checks if the value is within the specified range
//:: Returns the Default parameter is the range is exceeded, otherwise //:: Returns the Default parameter is the range is exceeded, otherwise
//:: the value is returned. //:: the value is returned.
@ -80,6 +90,24 @@ begin
Result := -1; Result := -1;
end; end;
function CompareFloat(const AValue1, AValue2: Single): Integer;
begin
Result := 0;
if AValue1 > AValue2 then
Result := 1
else if AValue1 < AValue2 then
Result := -1;
end;
function CompareFloat(const AValue1, AValue2: Double): Integer;
begin
Result := 0;
if AValue1 > AValue2 then
Result := 1
else if AValue1 < AValue2 then
Result := -1;
end;
function InRange; function InRange;
begin begin
Result := ADefault; Result := ADefault;