[fpc-devel] Abs(Variant) unexpected result
Jonas Maebe
jonas at freepascal.org
Sun Feb 25 17:01:23 CET 2018
On 25/02/18 16:41, Bart wrote:
> Delphi 10.2 Tokyo:
>
> X = -1,5
> VarIsFloat : TRUE
> VarIsNumeric: TRUE
> VarIsOrdinal: FALSE
> After Abs()
> X = 1,5
> VarIsFloat : TRUE
> VarIsNumeric: TRUE
> VarIsOrdinal: FALSE
>
> I asked to test with "X := -1" to see if Delphi always chooses the
> float overload.
As Michael said, overloads are selected at compile time. This is true
for both FPC and Delphi. We even have over a 100 unit tests that we ran
under Delphi to reverse engineer their selection priorities in case of
variants: https://svn.freepascal.org/svn/fpc/trunk/tests/test/cg/variants/
Abs(), however, gets a forced conversion to float in Delphi:
https://bugs.freepascal.org/view.php?id=20551
Jonas
More information about the fpc-devel
mailing list