Editions Ideas
Timon Gehr
timon.gehr at gmx.ch
Thu Dec 18 14:02:58 UTC 2025
On 12/18/25 06:04, Walter Bright wrote:
> On 12/14/2025 8:02 PM, Timon Gehr wrote:
>> To be fair, D does have a broken floating point implementation.
>
> Only insofar as the x87's implementation.
> ...
https://dlang.org/spec/float.html
>
>> Which then by the D spec does not matter because D is actually allowed
>> to randomly use the wrong floating point types and introduce
>> additional conversions and rounding imprecision.
>
> This was fixed a few years ago,
https://dlang.org/spec/float.html
> excepting that we do what everyone else does with the x87.
> ...
This can't really be true, because there is not even a single x87
behavior that is used.
https://github.com/dlang/dmd/issues/20339
We might or might not use the x87 even when there is no `real` involved
anywhere and we are working strictly with `float` or `double` data.
Neither `float` nor `double` arithmetic is even supported by the x87
unless you configure it to not do double rounding, and you have to write
back to memory after every operation to catch out-of-range exponents.
(Afaiu none of the D implementations do any of this.)
https://dlang.org/spec/float.html
>
>> Here's another recent complaint:
>> https://forum.dlang.org/thread/hvftxmrqvrmficcvlkqi@forum.dlang.org
>
> Different compilers have different long double sizes.
> ...
Not the problem, D does not have "long double", and we do not even have
to use `real` to get the broken behavior. If you read that thread,
obviously equivalent D code that executes the same float operations on
the same declared types (`double`!) in the same order works correctly
only when the optimizer happens to feel like it. (This is comparing D
code to D code, no "long double" or `real` or any other
implementation-defined floating-point storage type involved.)
> None of that has anything to do with NaN behavior.
The justification of not wanting to have a broken floating point
implementation applies in all of these cases.
Anyway, this is on topic, because changing e.g., constant folding to
work correctly can be a breaking change.
More information about the Digitalmars-d
mailing list