mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 22:29:24 +02:00
* Implement ConvUtils.ConvUnitCompareValue and ConvUtils.ConvUnitSameValue bug
#39768
(cherry picked from commit 7da3e17571
)
This commit is contained in:
parent
25986a6398
commit
3c778ccfb6
@ -27,7 +27,7 @@ interface
|
||||
|
||||
{$ifndef FPUNONE}
|
||||
uses
|
||||
sysutils;
|
||||
sysutils, math;
|
||||
|
||||
Type TConvType = type Integer;
|
||||
TConvFamily = type Integer;
|
||||
@ -47,6 +47,11 @@ function Convert ( const Measurement : Double; const FromType1, FromType2, ToTy
|
||||
function ConvertFrom(const AFrom: TConvType; AValue: Double): TConvUtilFloat;
|
||||
function ConvertTo(const AValue: Double; const ATo: TConvType): TConvUtilFloat;
|
||||
|
||||
function ConvUnitCompareValue(const AValue1: Double; const AType1: TConvType;
|
||||
const AValue2: Double; const AType2: TConvType): TValueRelationship;
|
||||
function ConvUnitSameValue(const AValue1: Double; const AType1: TConvType;
|
||||
const AValue2: Double; const AType2: TConvType): Boolean;
|
||||
|
||||
function ConvFamilyToDescription(const AFamily: TConvFamily): string;
|
||||
function ConvTypeToDescription(const AType: TConvType): string;
|
||||
function DescriptionToConvFamily(const ADescription: String; out AFamily: TConvFamily): Boolean;
|
||||
@ -112,6 +117,7 @@ Type ResourceData = record
|
||||
var TheUnits : array of ResourceData =nil;
|
||||
TheFamilies : array of string =nil;
|
||||
|
||||
|
||||
function ConvFamilyToDescription(const AFamily: TConvFamily): string;
|
||||
|
||||
begin
|
||||
@ -371,6 +377,25 @@ begin
|
||||
result:=Avalue/torec.value;
|
||||
end;
|
||||
|
||||
function ConvUnitCompareValue(const AValue1: Double; const AType1: TConvType;
|
||||
const AValue2: Double; const AType2: TConvType): TValueRelationship;
|
||||
|
||||
var
|
||||
D1, D2: TConvUtilFloat;
|
||||
|
||||
begin
|
||||
D1:=ConvertFrom(AType1, AValue1);
|
||||
D2:=ConvertFrom(AType2, Avalue2);
|
||||
result:=CompareValue(D1,D2,macheps);
|
||||
end;
|
||||
|
||||
function ConvUnitSameValue(const AValue1: Double; const AType1: TConvType;
|
||||
const AValue2: Double; const AType2: TConvType): Boolean;
|
||||
begin
|
||||
result:=ConvUnitCompareValue(Avalue1, AType1, AValue2, AType2)=0;
|
||||
end;
|
||||
|
||||
|
||||
Constructor TConvTypeInfo.Create(Const AConvFamily : TConvFamily;const ADescription:String);
|
||||
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user