Hi Florian,

Thanks for your reply. Initially I had all the data types as Double in the Object Pascal example. I then thought that maybe there is some auto data-type conversion, and tried storing the result in a Extended type instead. It made no difference.

From your example, the only time there is a difference is when the -Cfsse2 is specified. What exactly does that do, because with or without that, the results vary.

I'm running 64-bit Windows 10 here, but using FPC 3.0.4 32-bit compiler. In Delphi I was using XE3 32-bit compiler as well.

See here... I changed all the data types to Double before I did this test:

graeme.geldenhuys@UKCM-L500737 C:\devel\tests\OperatorPrecedence
fpc -Criot -Cfsse3 TestOperatorPrecedence.pas
Free Pascal Compiler version 3.0.2 [2017/02/13] for i386
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling TestOperatorPrecedence.pas
TestOperatorPrecedence.pas(10,3) Note: Local variable "a" is assigned but never used
Linking TestOperatorPrecedence.exe
36 lines compiled, 0.1 sec, 35312 bytes code, 2436 bytes data
1 note(s) issued

graeme.geldenhuys@UKCM-L500737 C:\devel\tests\OperatorPrecedence
TestOperatorPrecedence.exe
 5.1009900000000001E+004
 5.1009900000000001E+004
 5.1009900000000001E+004
---
 0.0000000000000000E+000
 0.0000000000000000E+000
 0.0000000000000000E+000
 0.0000000000000000E+000
 0.0000000000000000E+000



Perfect, the result I expected. Now the same code, but compiled without -Cfsse2 and the results change.


graeme.geldenhuys@UKCM-L500737 C:\devel\tests\OperatorPrecedence
fpc -Criot TestOperatorPrecedence.pas
Free Pascal Compiler version 3.0.2 [2017/02/13] for i386
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling TestOperatorPrecedence.pas
TestOperatorPrecedence.pas(10,3) Note: Local variable "a" is assigned but never used
Linking TestOperatorPrecedence.exe
36 lines compiled, 0.1 sec, 35232 bytes code, 2436 bytes data
1 note(s) issued

graeme.geldenhuys@UKCM-L500737 C:\devel\tests\OperatorPrecedence
TestOperatorPrecedence.exe
 5.1009900000000001E+004
 5.1009900000000001E+004
 5.1009900000000001E+004
---
-3.5527136788005009E-015
-3.5527136788005009E-015
-3.5527136788005009E-015
 0.0000000000000000E+000
 0.0000000000000000E+000


Sorry, but this makes no sense to me.

Regards,
  Graeme


On 2018-10-03 10:16, Florian Klämpfl wrote:
Am 03.10.2018 um 10:40 schrieb mailingli...@geldenhuys.co.uk:
I have this simple little test. My expected answer for all the calculations are 0 (zero), but both FPC and Delphi give different results. Java is the only one that seems consistent regarding the results.

Compile/run on the same architecture, use the same data types (and not
extended for Object Pascal and double for Java).
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to