Printing shortest decimal form of floating point number with Mir
Timon Gehr
timon.gehr at gmx.ch
Wed Jan 6 09:20:34 UTC 2021
On 06.01.21 07:50, Walter Bright wrote:
>
> > I want to execute the code that I wrote, not what you think I should
> have
> > instead written, because sometimes you will be wrong.
>
> With programming languages, it does not matter what you think you wrote.
> What matters is how the language semantics are defined to work.
The language semantics right now are defined to not work, so people are
going to rely on the common sense and/or additional promises of specific
backend authors. People are going to prefer that route to the
alternative of forking every dependency and adding explicit rounding to
every single floating-point operation. (Which most likely does not even
solve the problem as you'd still get double-rounding issues.)
> In writing professional numerical code, one must carefully understand it,
> knowing that it does *not* work like 7th grade algebra.
That's why it's important to have precise control. Besides, a lot of
contemporary applications of floating-point computations are not your
traditional numerically stable fixed-point iterations. Reproducibility
even of explicitly chaotic behavior is sometimes a big deal, for example
for artificial intelligence research or multiplayer games.
Also, maybe you don't want your code to change behavior randomly between
compiler updates. Some applications need to have a certain amount of
backwards compatibility.
> Different languages can and do behave differently, too.
Or different implementations. I'm not going to switch languages due to
an issue that's fixed by not using DMD.
More information about the Digitalmars-d-announce
mailing list