Printing shortest decimal form of floating point number with Mir

Timon Gehr timon.gehr at gmx.ch
Wed Jan 6 05:57:17 UTC 2021


On 06.01.21 03:27, Walter Bright wrote:
> On 1/5/2021 5:30 AM, Guillaume Piolat wrote:
>> It would be nice if no excess precision was ever used. It can 
>> sometimes gives a false sense of correctness. It has no upside except 
>> accidental correctness that can break when compiled for a different 
>> platform.
> 
> That same argument could be use to always use float instead of double. I 
> hope you see it's fallacious <g>
> ...

Evidence that supports some proposition may well fail to support a 
completely different proposition.

An analogy for your exchange:

G: Birds can fly because they have wings.
W: That same argument could be used to show mice can fly. I hope you see 
it's fallacious <g>


Anyway, I wouldn't necessarily say occasional accidental correctness is 
the only upside, you also get better performance and simpler code 
generation on the deprecated x87. I don't see any further upsides 
though, and for me, it's a terrible trade-off, because possibility of 
incorrectness and lack of portability are among the downsides.

I want to execute the code that I wrote, not what you think I should 
have instead written, because sometimes you will be wrong. There are 
algorithms in Phobos that can break when certain operations are computed 
at a higher precision than specified. Higher does not mean better; not 
all adjectives specify locations on some good/bad axis.


More information about the Digitalmars-d-announce mailing list