mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 02:48:07 +02:00
parent
c87facbae1
commit
0cb85eef9b
@ -2791,6 +2791,29 @@ implementation
|
||||
tordconstnode(right).value:=tordconstnode(right).value div 10000
|
||||
else
|
||||
{$endif VER3_0}
|
||||
if (right.nodetype=muln) and is_currency(right.resultdef) and
|
||||
{ do not test swapped here as the internal conversions are only create as "var."*"10000" }
|
||||
is_currency(taddnode(right).right.resultdef) and (taddnode(right).right.nodetype=ordconstn) and (tordconstnode(taddnode(right).right).value=10000) and
|
||||
is_currency(taddnode(right).left.resultdef) and (taddnode(right).left.nodetype=typeconvn) then
|
||||
begin
|
||||
hp:=taddnode(right).left.getcopy;
|
||||
include(hp.flags,nf_is_currency);
|
||||
right.free;
|
||||
right:=hp;
|
||||
hp:=nil;
|
||||
end
|
||||
else if (left.nodetype=muln) and is_currency(left.resultdef) and
|
||||
{ do not test swapped here as the internal conversions are only create as "var."*"10000" }
|
||||
is_currency(taddnode(left).right.resultdef) and (taddnode(left).right.nodetype=ordconstn) and (tordconstnode(taddnode(left).right).value=10000) and
|
||||
is_currency(taddnode(left).left.resultdef) and (taddnode(left).left.nodetype=typeconvn) then
|
||||
begin
|
||||
hp:=taddnode(left).left.getcopy;
|
||||
include(hp.flags,nf_is_currency);
|
||||
left.free;
|
||||
left:=hp;
|
||||
hp:=nil;
|
||||
end
|
||||
else
|
||||
begin
|
||||
hp:=cmoddivnode.create(divn,getcopy,cordconstnode.create(10000,s64currencytype,false));
|
||||
include(hp.flags,nf_is_currency);
|
||||
|
@ -1,4 +1,4 @@
|
||||
program tcurrency;
|
||||
program tcurrency1;
|
||||
|
||||
{ test basic mathematical operations (+,-,*,/) using currency data type }
|
||||
|
||||
@ -69,6 +69,17 @@ begin
|
||||
writeln('Invalid currency*integer=', i*c1, ', but expected ', c2);
|
||||
halt(2);
|
||||
end;
|
||||
i:=10000;
|
||||
c1:=92233720368.5477;
|
||||
c2:=922337203685477;
|
||||
if c1*i <> c2 then begin
|
||||
writeln('Invalid currency*integer=', c1*i, ', but expected ', c2);
|
||||
halt(2);
|
||||
end;
|
||||
if i*c1 <> c2 then begin
|
||||
writeln('Invalid integer*currency=', i*c1, ', but expected ', c2);
|
||||
halt(2);
|
||||
end;
|
||||
// division integer
|
||||
i := 1000;
|
||||
c1 := 123.4;
|
||||
|
Loading…
Reference in New Issue
Block a user