* patch by Евгений Савин to make Variant to string convertion use CurrToStr for varCurrency, resolves #40624

This commit is contained in:
florian 2024-02-04 14:10:49 +01:00
parent 9ac0a54ad2
commit b6ccf369b9
2 changed files with 26 additions and 4 deletions

View File

@ -1283,7 +1283,7 @@ begin
{$ifndef FPUNONE}
varSingle : Result := FloatToStr(vSingle);
varDouble : Result := FloatToStr(vDouble);
varCurrency : Result := FloatToStr(vCurrency);
varCurrency : Result := CurrToStr(vCurrency);
varDate : Result := VarDateToString(vDate);
{$endif}
varBoolean : Result := BoolToStr(vBoolean, True);
@ -1306,7 +1306,7 @@ begin
{$ifndef FPUNONE}
varSingle : Result := FloatToStr(PSingle(vPointer)^);
varDouble : Result := FloatToStr(PDouble(vPointer)^);
varCurrency : Result := FloatToStr(PCurrency(vPointer)^);
varCurrency : Result := CurrToStr(PCurrency(vPointer)^);
varDate : Result := VarDateToString(PDate(vPointer)^);
{$endif}
varBoolean : Result := BoolToStr(PWordBool(vPointer)^, True);
@ -1350,7 +1350,7 @@ begin
{$ifndef FPUNONE}
varSingle : Result := FloatToStr(vSingle);
varDouble : Result := FloatToStr(vDouble);
varCurrency : Result := FloatToStr(vCurrency);
varCurrency : Result := CurrToStr(vCurrency);
varDate : Result := VarDateToString(vDate);
{$endif}
varBoolean : Result := BoolToStr(vBoolean, True);
@ -1373,7 +1373,7 @@ begin
{$ifndef FPUNONE}
varSingle : Result := FloatToStr(PSingle(vPointer)^);
varDouble : Result := FloatToStr(PDouble(vPointer)^);
varCurrency : Result := FloatToStr(PCurrency(vPointer)^);
varCurrency : Result := CurrToStr(PCurrency(vPointer)^);
varDate : Result := VarDateToString(PDate(vPointer)^);
{$endif}
varBoolean : Result := BoolToStr(PWordBool(vPointer)^, True);

22
tests/webtbs/tw40624.pp Normal file
View File

@ -0,0 +1,22 @@
program tw40624;
uses
SysUtils
{ you can add units after this };
var
C: Currency;
V: Variant;
S: string;
begin
C := 822337203685477.5807;
V := C;
DefaultFormatSettings.DecimalSeparator := '.';
if CurrToStr(C) <> '822337203685477.5807' then
Halt(1);
S := V;
if S <> '822337203685477.5807' then
Halt(2);
WriteLn('OK');
end.