Compilation error with power of ten in old code

173 Views Asked by At

I am experiencing an issue with an old Delphi program (I can read comments saying "last edit 21/09/1992")

When I load the project with the latest Delphi 11, there are compilation errors:

value := 5.E-3

E2003 Error: Identifier undeclared 'E' line xxx

I believe it means 5 * 10-3, ie 0.005.

To make this line compile, I removed the dot, I now have

value := 5E-3

Unfortunately, the test using this line does not execute properly, since it is the only modification I made, and the code is not commented (except some dates from last centurys). I wonder if my fix was correct by removing the dot.

Has there been a syntax modification in the language that is documented (Delphi 7 to Delphi 11)?

I have hundreds of these "5.E-3" and I want to be certain my correction is correct.

1

There are 1 best solutions below

1
SilverWarior On

Based on how old your code is it may well originate from Turbo Pascal.

Turbo Pascal did not support floating point numbers like modern Delphi does so I'm guessing that the type of your value variable is Real. But that is not the same type as System.Real.

Instead in Turbo Pascal real type had different data structure as you can read at Turbo Pascal Real.

This means that even if you manage to make suitable changes in your code so that all those numbers are represented with correct scientific notation that Delphi accepts the actual value of the number may not be the same as it was in Turbo Pascal due to difference of how Turbo Pascal and modern Delphi versions are treating Real type.