Sorting floating-point values, and NaN

Vladimir Panteleev vladimir at thecybershadow.net
Wed Nov 13 11:28:26 PST 2013


On Tuesday, 12 November 2013 at 20:03:37 UTC, Andrei Alexandrescu 
wrote:
>> 2) Improve documentation and visibility of this problem. For 
>> example,
>> add this to the documentation of sort:
>>
>> "The predicate must be transitive (`a<b && b<c` implies `a<c`) 
>> in order
>> for `sort` to behave properly - otherwise, the program may 
>> fail on
>> certain inputs (but not others) when not compiled in release 
>> mode. Note
>> that `a<b` is not transitive for floating points, because the 
>> expression
>> will always be `false` when either `a` or `b` is `NaN`."
>
> Great idea, just file an enh request or just write the pull 
> request.

https://github.com/D-Programming-Language/phobos/pull/1691


More information about the Digitalmars-d mailing list