[fpc-pascal] Loss of precision when using math.Max()
Florian Klaempfl
florian at freepascal.org
Mon Jul 9 20:13:11 CEST 2018
Am 09.07.2018 um 19:55 schrieb gtt at wolfgang-ehrhardt.de:
>
> Zitat von Martok <listbox at martoks-place.de>:
>> To make sure this works, one has to manually make the const expression
>> be of the
>> type required:
>> const
>> e: Extended = Extended(1.0) / 3.0;
>>
>> I seem to remember that this was once documented somewhere for Delphi.
>> Can't
>> seem to find it though, so maybe it was a 3rd-party book? There is no
>> hint of it
>> in the FPC documentation, anyway.
>
> As already noted, it is not necessary in Delphi
>
> D:\Work\TMP>D:\DMX\M18\DCC32 -b exttest.dpr
> Embarcadero Delphi for Win32 compiler version 25.0
> Copyright (c) 1983,2013 Embarcadero Technologies, Inc.
> exttest.dpr(14)
> 15 lines, 0.00 seconds, 20816 bytes code, 13864 bytes data.
> D:\Work\TMP>exttest
> 0.3333333433 0.3333333433
> 0.3333333333333333 0.3333333333333333
> 0.3333333333333333 0.3333333333333333
>
> And with Delphi Tokio 10.2.3 Starter
>
> G:\TMP>bds -b exttest.dpr
> G:\TMP>exttest.exe
> 0.3333333433 0.3333333433
> 0.3333333333333333 0.3333333333333333
> 0.3333333333333333 0.3333333333333333
I am happy to implement this in delphi mode, but it requires some
documentation references how delphi evaluates such expressions (which
precision is used when and why) and how they are handled in expressions.
More information about the fpc-pascal
mailing list