Sorting floating-point values, and NaN

tn no at email.com
Tue Nov 12 12:24:56 PST 2013


On Tuesday, 12 November 2013 at 19:39:19 UTC, Vladimir Panteleev 
wrote:
> On Tuesday, 12 November 2013 at 19:26:12 UTC, tn wrote:
>> Thus, the correct solution would be to modify the functions to 
>> take "lessOrEqual" as a template parameter instead of "less".
>
> Too late for that now... just like it's too late to change IEEE 
> comparison logic.

Yes, I was expecting this. :)

>> If "less" is kept, then we need another template argument to 
>> separate equality and incomparability (something like 
>> "equals(a,b)", or "incomparable(a,b)").
>
> Is this to allow generic partial ordering (rather than to fix 
> sorting NaNs specifically)? I remember seeing a thread about 
> partial ordering and opCmp:
> http://forum.dlang.org/post/dpfbtu$1ocf$1@digitaldaemon.com

I had generic partial orderings in my mind too, but I think it is 
also needed for user defined floating point types such as 
bigfloat. (Unless "isnan" function is defined for the bigfloat 
type too and detected automatically.)


More information about the Digitalmars-d mailing list