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
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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;
  s := 123.145;
  e := 123.145;
  ShowMessage(FloatToStrF(s, ffNumber, 5, 2));
  ShowMessage(FloatToStrF(e, ffNumber, 5, 2));

 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.
thirdAuthor 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. :-)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 :)

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.