[fpc-devel] IntFloatToTextFmt question

Bart bartjunk64 at gmail.com
Wed Oct 12 11:42:35 CEST 2022


Hi,

In #989895c8 I introduced a check for NaN in the IntFloatToTextFmt function.
This check is performed on the untyped parameter Value, typecasted to
Extended (or possibly Currency) (variable E).
As it turns out this only evaluated to True if Value actually is an Extended.
If you would call the function with a Single or Double (on systems
where Double <> Extended), E.IsNan would evaluate to FALSE.

The original issue was about FormatFloat,I tested that (before
submitting) with single, double and extended variables set to NaN and
in all cases the E.IsNaN returned TRUE.
The above observation made me curious: why does it work with FormatFloat.
As it turns out FormatFloat uses Extended for it's Value parameter,
there are no overloads with Single, Double or Currency.
And FormatFloat seems to be the only function that calls IntFloatToTextFmt .
So, the patch merely works by accident?

And hence my question: why is the Value parameter in IntFloatToTextFmt
an untyped parameter?
I can imagine it was designed to be used by other  functions in the
future with other floating point types, but that never happend so far.
If it must remain an untyped parameter, then #989895c8 is wrong (it
should use the ValueType parameter and then figure out if it is NaN in
some way).

--
Bart


More information about the fpc-devel mailing list