On Sunday, 27 July 2014 at 18:22:50 UTC, Ola Fosheim Gr wrote:
On Sunday, 27 July 2014 at 18:00:29 UTC, Fool wrote:
Thus we do not have transitivity of incomparability:

You are right, I forgot to test the case where only c is NaN. Well, that makes floats suck even more! :-)

In fact, IEEE 754 was designed by brilliant people:

'Non-Extended encodings are all "Lexicographically Ordered", which means that if two floating-point numbers in the same format are ordered (say x < y), then they are ordered the same way when their bits are reinterpreted as Sign-Magnitude integers. Consequently, processors need no floating-point hardware to search, sort and window floating-point arrays quickly. (However, some processors reverse byte-order!)' [1]

Is a function for comparing floating-point numbers this way available in Phobos?

[1] W. Kahan: "Lecture Notes on the Status of IEEE Standard 754 for Binary Floating-Point Arithmetic", 1997. URL http://www.eecs.berkeley.edu/~wkahan/ieee754status/IEEE754.PDF

Reply via email to