View Issue Details

IDProjectCategoryView StatusLast Update
0030483FPCMiscpublic2016-09-22 10:12
ReporterYuri BruxelAssigned ToJonas Maebe 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformOSWindows 7 64-bit Service Pack 1OS Version
Product Version3.0.0Product BuildSVN 51630 
Target VersionFixed in Version 
Summary0030483: Real x Currency multiplication is not correct
DescriptionWhen multiplicating two variables, a real and a currency, the returned result is not correct.
Steps To ReproduceOn a form, places a TButton with the following code:

----------------------------------------------------
procedure TForm1.Button1Click(Sender: TObject);
var a : real;
    b : currency;
begin
     a := 1.1;
     b := 10;
     b := a*b+1;
     showmessage(currtostr(b));
end;
-----------------------

The expected display value for "b" would be "12", but it shows "110001".
Additional InformationOn Delphi it works as expected.

It also works on Linux (result is 12).

This bug occurs also on Windows 10.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Relationships

duplicate of 0028748 resolvedYuriy Sydorov Adding Double to Currency - wrong result 

Activities

Yuri Bruxel

2016-08-19 07:49

reporter   ~0094180

In fact, the problem is not related to data types. I've noticed the bug occurs to currency only operations, as shown.

The two codes below should be equivalent, but the first results in "1210" and second result in "0.121" which is the desired output.

------------------- 1st CODE -------

procedure TForm1.Button1Click(Sender: TObject);
var a , b, c : Currency;
begin
  a := 1.1;
  b := 10;
  c := a / b * a;
  ShowMessage(CurrToStr(c));
end;

-----------------------------

---------- 2nd CODE

procedure TForm1.Button1Click(Sender: TObject);
var a , b, c : Currency;
begin
  a := 1.1;
  b := 10;
  c := a / b;
  c := c * a;
  ShowMessage(CurrToStr(c));
end;

------------------------------

Cyrax

2016-08-19 08:30

reporter   ~0094181

Have you tested on the trunk? There were some fixes related to currency manipulation.

Marco van de Voort

2016-08-19 11:45

manager   ~0094185

Afaik the currency fixes were backported to the fixes branch

Jonas Maebe

2016-09-22 10:12

manager   ~0094767

The state of a problem should only be tracked in the original bug report, it shouldn't be duplicated everywhere.

Issue History

Date Modified Username Field Change
2016-08-19 06:19 Yuri Bruxel New Issue
2016-08-19 07:49 Yuri Bruxel Note Added: 0094180
2016-08-19 08:30 Cyrax Note Added: 0094181
2016-08-19 11:45 Marco van de Voort Note Added: 0094185
2016-08-21 14:03 LacaK Relationship added related to 0002874
2016-08-21 14:04 LacaK Relationship deleted related to 0002874
2016-08-21 14:04 LacaK Relationship added related to 0028748
2016-08-29 22:52 Jonas Maebe Relationship replaced duplicate of 0028748
2016-08-29 22:52 Jonas Maebe Status new => resolved
2016-08-29 22:52 Jonas Maebe Resolution open => fixed
2016-08-29 22:52 Jonas Maebe Assigned To => Jonas Maebe
2016-09-22 10:07 Yuriy Sydorov Fixed in Version => 3.0.2
2016-09-22 10:12 Jonas Maebe Note Added: 0094767
2016-09-22 10:12 Jonas Maebe Fixed in Version 3.0.2 =>