Am 16.02.2024 um 08:32 schrieb Florian Klämpfl via fpc-pascal:
Am 16.02.2024 um 08:23 schrieb Ern Aldo via fpc-pascal <fpc-pascal@lists.freepascal.org>:
 Compile-time math needs to be as correct as possible. RUN-time math can worry 
about performance.
So you are saying when constant propagation is on, an expression should have a 
different result than with constant propagation off?

I don't know exactly, what you mean by constant propagation.

But IMO, given this (sort of fictive) Pascal code snippet:


const Xconst : single = 1440.0;

var y1, y2 : real;

y1 := 33.0 / 1440.0;

y2 :=  33.0 / Xconst;


the division in the first assignment (to y1) should be done at maximum precision, that is, both constants should be converted by the compiler to the maximum available precision and
the division should be done (best at compile time) using this precision.

in the second case, if the compiler supports constants of the reduced type (which I believe it does, no matter how the syntax is), I find it acceptable if the computation is done using single precision,
because that's what the developer calls for.

So probably the answer to your question is: yes.

Kind regards

Bernd




_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to