DPStano 15 Posted July 26, 2021 (edited) I have program like E: Extended; E := 36678971.91; Writeln(FormatFloat('0.##########', E, FloatFormatSettings)); result is 36678971.91 SizeOf(Extended) > 10, GetPrecisionMode -> pmExtended, GetRoundMode ->rmNearest but when I compile it with CI dcc32.exe with almost same params the result is 36678971.9099999994, SizeOf(Extended) > 10, GetPrecisionMode -> pmDouble, GetRoundMode ->rmNearest I thought that precision mode will make it different but no when I SetPrecisionMode(pmExtended) result will not change Does anybody have any idea what is happening? Edited July 26, 2021 by DPStano Share this post Link to post
FPiette 385 Posted July 26, 2021 Please show a complete minimal reproducible example project. Share this post Link to post
DPStano 15 Posted July 26, 2021 (edited) I can't create a minimal example ... just want to know if anybody knows what else can influence floating-point arithmetics in Delphi (some compiler directive, some other function something undocumented... some missing include... ) program Project14; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, math; var E: Extended; begin FloatFormatSettings := TFormatSettings.Create(''); FloatFormatSettings.DecimalSeparator := '.'; FloatFormatSettings.ThousandSeparator := #0; E := 36678971.91; Writeln(FormatFloat('0.##########', E, FloatFormatSettings)); end. I can't share the CI build script but params are like (bellow) with a bunch of system and internal units and libraries $flags = @{ 'A'='AGenerics.Collections=System.Generics.Collections;Generics.Defaults=System.Generics.Defaults;WinTypes=Winapi.Windows;WinProcs=Winapi.Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;'; 'NS'='Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;WinAPI.Foundation;System.Win;FMX;'; 'B' = ''; 'GD' = ''; 'DRELEASE' = ''; 'DCI' = ''; 'W' = '-SYMBOL_PLATFORM'; '$W+' = ''; '$C-' = '' } Edited July 26, 2021 by DPStano Share this post Link to post
FPiette 385 Posted July 26, 2021 OK, now compile your sample with Delphi IDE and with DCC32 and share the results. Share this post Link to post
DPStano 15 Posted July 26, 2021 it's not a minimal example ... it will take few days to add it to our build system (will try it for sure), I've just tried it in the new branch ... but I can guess that it will return 36678971.91 😄 there is something that has an influence on the result ... but I can't find what. Share this post Link to post
Lajos Juhász 295 Posted July 26, 2021 My first guess is that you're comparing the result of a 32 bit and 64 bit applications. In 64 bit Extened = Double. Share this post Link to post
DPStano 15 Posted July 26, 2021 Delphi is 10.3.0, app is 32bit (my build and CI too), OS is Windows10 and Windows server 2016 (CI) Share this post Link to post
FPiette 385 Posted July 26, 2021 The IDE and dcc32 are the same compiler so using the same compiler switch should result in the same code. I suspect - as it is often the case - that you extracted the code for a more complex application and there is something interfering that you didn't see. That's why I asked you to create a minimal example reproducing the problem. Now you have the code and you have to test the result with both the IDE et dcc32. Share this post Link to post
DPStano 15 Posted July 27, 2021 as I thought simple app returns 36678971.91 (built with CI) ... now I have like 2kk lines of legacy code with 2kk lines of external dependencies ... so back to the question is there any function besides SetPrecisionMode and SetRoundMode that can have an impact on floating points numbers? Share this post Link to post
FPiette 385 Posted July 27, 2021 (edited) Floating point numbers are a difficult subject. To have a better idea, read this article: http://rvelthuis.de/articles/articles-floats.html Be sure to have a look at the references at the end of the article. FPU Control Word can also be affected by components or libraries and then change the behavior. Look at this documentation http://docwiki.embarcadero.com/RADStudio/Sydney/en/Category:Floating-Point Edited July 27, 2021 by FPiette Share this post Link to post
David Heffernan 2353 Posted July 27, 2021 Log the floating point control word and see if it is the same in the two programs. Share this post Link to post
DPStano 15 Posted July 27, 2021 I found what is interfering there was background loading of TWebBrowser that changes precision in FPU Control Word thx all 1 Share this post Link to post