Always false float comparisons

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Mon May 16 04:50:54 PDT 2016


On 5/16/2016 4:18 AM, Joseph Rushton Wakeling wrote:
> you keep saying "correctness" or "accuracy", when people are
> consistently talking to you about "consistency" ... :-)

I see consistently wrong answers as being as virtuous as getting tires for my 
car that are not round :-)


> I can always request more precision if I need or want it.  Getting different
> results for a superficially identical float * double calculation, because one
> was performed at compile time and another at runtime, is an inconsistency that
> it might be nicer to avoid.

As the links I posted explain in great detail, such a design produces other 
problems. Secondly, as I think this thread amply demonstrates, few programmers 
are particularly aware of the issues of cumulative roundoff error. It's very 
easy to miss it and just assume the result of the calculation is precise to 7 
digits, when it might be off by factors of 2.


> The latter result, at least (AIUI) is consistent depending on whether the
> calculation is done at compile time or runtime.

True, but I was talking about intuitiveness. Integral promotion rules are not 
intuitive, they are a surprise to every C/C++/D newbie. Except for me, since I 
came from a PDP-11 assembler background, and that's how the PDP-11 CPU worked, 
and C's semantics are based on the 11.


More information about the Digitalmars-d mailing list