[fpc-pascal] Floating point question

Florian Klämpfl florian at freepascal.org
Sun Feb 4 18:37:18 CET 2024


Am 04.02.2024 um 18:25 schrieb James Richters via fpc-pascal:
> I agree with Aadrian 100%
>   
> "New behaviour: floating point constants are now considered to be of the lowest precision which doesn't cause data loss"
> 
> We are getting data loss!!!! So it's doing it WRONG.
> 
> So we are all living with a stupid way of doing things so some Delphi code won't have warnings?
> 
> Who came up with this???????????????
> 
> The old way was CORRECT,   instead of changing it for everyone making it wrong for most users, a compiler directive should have been needed to get rid of the warnings, or ONLY applied in Mode Delphi.  Not to make everything incorrect for everyone unless you add a directive.     The problem with this that no one is expecting to need to add a directive to do things right.
> 
> Consider this:
>   
> Var
>    MyVariable : Extended;
> 
> MyVariable := 8427 + 33 / 1440.0;
> 
> Since I am storing the result in an Extended, I DO NOT EXPECT the 33/1440 to be a SINGLE, that is NUTS!!

No need to yell.

This is how reasonable programing languages work. The result type depends only on the type of the involved 
variables/expressions. *Never* the variable it is assigned to.



More information about the fpc-pascal mailing list