Always false float comparisons

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sat May 21 14:56:02 PDT 2016


On 5/21/2016 11:36 AM, Tobias M wrote:
> Sorry but this is a misrepresentation. I never claimed that the x87 doesn't
> conform to the IEEE standard.

My point was directed to more than just you. Sorry I didn't make that clear.


> The point is, that is IS possible to provide fairly reasonable and consistent
> semantics within the existing standards (C, C++, IEEE, ...).

That implies what I propose, which is what many C/C++ compilers do, is 
unreasonable, inconsistent, not Standard compliant, and not IEEE. I.e. that the 
x87 is not conformant :-)

Read the documentation on the FP switches for VC++, g++, clang, etc. You'll see 
there are tradeoffs. There is no "obvious, sane" way to do it.

There just isn't.


> They provide a
> certain degree of freedom to accomodate for different hardware, but this doesn't
> mean that software should use this freedom to do arbitrary things.

Nobody is suggesting doing arbitrary things, but to write portable fp, take into 
account what the Standard says rather than what your version of the compiler 
does with various default and semi-documented switches.


> Regarding the decades of FP design, the initial edition of K&R C contained the
> following clause:
> "Notice that all floats in an expression are converted to double; all floating
> point arithmethic in C is done in double precision".
> That passus was removed quite quickly because users complained about it.

It was changed to allow floats to be computed as floats, not require it. And the 
reason at the time, as I recall, was to get faster floating point ops, not 
because anyone desired reduced precision.



More information about the Digitalmars-d mailing list