Delphi 2007 precision

I have an application previously written in Delphi 7 but recently compiled to Delphi 2007. Everything was fine until we found out that the figures on the reports generated on Delphi 2007 was quite far from the result produced by Delphi 7. Nothing on the code was changed except it was recompiled on the higher version. Variable types declared as double. The formulas used are quite complex so I couldn't post here. Has anyone experienced the same? Is there a way to maintain the same precision Delphi 7 uses? Thanks.
LVL 30
thirdAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
thirdConnect With a Mentor Author Commented:
Finally found the culprit! After turning off optimization on the compiler options, the generated figures on both version are now the same. For some reason, the original programmer in Delphi 7 turned this off. The other weird thing is that Delphi 2007 did not use the same optimization setting from the old version but enabled it instead. But I'm so glad this was resolved now. I have spent my day digging this bug.

I appreciate everyone's help. If everyone agrees this is worth to be PAQed? I'm also generous if you like. :-)
0
 
ziolkoConnect With a Mentor Commented:
not sure if that's what you ask about, but sometime ago friend of mine had problem with precision when using FloatToStrF()

see this:
procedure TForm1.Button5Click(Sender: TObject);
var s: Single;
    e: Extended;
begin
  s := 123.145;
  e := 123.145;
  ShowMessage(FloatToStrF(s, ffNumber, 5, 2));
  ShowMessage(FloatToStrF(e, ffNumber, 5, 2));
end;

ziolko.
0
 
developmentguruConnect With a Mentor PresidentCommented:
 I would really start debugging on both (D7 and 2007) and see where the difference occurs.  I would more suspect the reporting solution (or difference in the reporting solution).  Start by running any query(ies) that generate data and examine the results.  Then check the results of the formula at each stage.  If the formula is being done in one massive statement, break it up into separate results and watch the results of each step.  You will likely find out that one of the intermediate steps produced a result in a lower precision.  Separating the steps and assigning the result to Double will allow you to dictate what the intermediate result is generated as.

  Without the ability to step in and do the debugging myself I will have to rely on the information you give us.
0
 
ziolkoConnect With a Mentor Commented:
from Delphi help:
"All optimizations performed by the Delphi compiler are guaranteed not to alter the meaning of a program. In other words, the compiler performs no "unsafe" optimizations that require special awareness by the programmer. "

little lying bastards :)

ziolko.
0
All Courses

From novice to tech pro — start learning today.