[fpc-pascal] Floating point question

James Richters james.richters at productionautomation.net
Tue Feb 13 12:12:23 CET 2024


>As Jonas said, this would result in less efficient code, since all the math
will then be done at full precision, which is slower.
I don't think I'm explaining it well,  I'm saying where there is an entire
formula that the compiler needs to evaluate, what's happening now, is that
each term is being reduced in precision first, Then the math happens, and
the result it stored.  
If instead the compiler did all the math first, THEN ran the function that
determines if the entire answer should be reduced in precision, then the
math would work correctly. 

But we don't care how long it takes to do the math during the compile, the
constants are only compiled once and stored in the executable.   The reason
to do all this is to make the executing program that ends up using the
constants over and over many times more efficient, the speed of the
compilation is irrelevant.

>As usual, it is a trade-off between size (=precision) and speed.
I agree with that, but only in the executing program, not the compiler.  

James



More information about the fpc-pascal mailing list