What is the proper way to use $EXCESSPRECISION ? I tried:
program TESTDBL1 ;
{$EXCESSPRECISION ON}
Const
TT_Const = 8427 + 33 / 1440.0 ;
SS_Const = 8427 + Double(33 / 1440.0) ;
Begin
WRITELN ( 'TT_Const = 8427 + 33 / 1440.0 ; =' ,
TT_Const : 20 : 20 ) ;
WRITELN ( 'SS_Const = Double(8427 + 33 / 1440.0); =' ,
SS_Const : 20 : 20 ) ;
end.
I get
TT_Const = 8427 + 33 / 1440.0 ;
=8427.02246100000000000000
SS_Const = Double(8427 + 33 / 1440.0);
=8427.02291666716340000000
I expected them to be both the same.
James
-----Original Message-----
From: fpc-pascal <[email protected]> On Behalf Of James
Richters via fpc-pascal
Sent: Sunday, February 4, 2024 10:52 AM
To: 'FPC-Pascal users discussions' <[email protected]>
Cc: James Richters <[email protected]>
Subject: Re: [fpc-pascal] Floating point question
Hi Jonas,
That’s Interesting, Thank you very much for the links!! Not only an
explanation but a solution.
The original is how I would expect it to work, If it's for Delphi
compatibility why not only do that when in Mode Delphi? If not in mode Delphi
who cares if it's compatible?
Delphi is completely wrong to do it this way.
I'm glad there is $EXCESSPRECISION I am Immediately putting that in every
single program I have, because that is I always thought it would work, and I do
have divisions where this can be a problem.
James
-----Original Message-----
From: fpc-pascal < <mailto:[email protected]>
[email protected]> On Behalf Of Jonas Maebe via fpc-pascal
Sent: Sunday, February 4, 2024 7:21 AM
To: <mailto:[email protected]> [email protected]
Cc: Jonas Maebe < <mailto:[email protected]> [email protected]>
Subject: Re: [fpc-pascal] Floating point question
On 03/02/2024 18:42, James Richters via fpc-pascal wrote:
> Constants are also evaluated wrong,you don’t know what that constant
> is going to be used for, so all steps of evaluating a constant MUST be
> done in extended by the compiler, or the answer is just wrong.
See
<https://wiki.freepascal.org/User_Changes_2.2.0#Floating_point_constants>
https://wiki.freepascal.org/User_Changes_2.2.0#Floating_point_constants
and <https://www.freepascal.org/daily/doc/prog/progsu19.html>
https://www.freepascal.org/daily/doc/prog/progsu19.html
fpc-pascal maillist - <mailto:[email protected]>
[email protected]
<https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal>
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist - [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal