Always false float comparisons

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Mon May 16 01:10:02 PDT 2016


On 5/15/2016 11:00 PM, Ola Fosheim Grøstad wrote:
> On Sunday, 15 May 2016 at 22:49:27 UTC, Walter Bright wrote:
>> On 5/15/2016 2:06 PM, Ola Fosheim Grøstad wrote:
>>> The net result is that adding const/immutable to a type can change the semantics
>>> of the program entirely at the whim of the compiler implementor.
>>
>> C++ Standard allows the same increased precision, at the whim of the compiler
>> implementor, as quoted to you earlier.
>>
>> What your particular C++ compiler does is not relevant, as its behavior is not
>> required by the Standard.
>
> This is a crazy attitude to take. C++ provides means to detect that IEEE floats
> are being used in the standard library.

IEEE floats do not specify precision of intermediate results. A C/C++ compiler 
can be fully IEEE compliant and yet legitimately have increased precision for 
intermediate results.

I posted several links here pointing out this behavior in VC++ and g++. If your 
C++ numerics code didn't have a problem with it, it's likely you wrote the code 
in such a way that more accurate answers were not wrong.

FP behavior has complex trade-offs with speed, accuracy, compatibility, and 
size. There are no easy, obvious answers.


More information about the Digitalmars-d mailing list