[swift-evolution] [Proposal draft] Enhanced floating-point protocols

Stephan Tolksdorf st at quanttec.com
Fri Apr 15 13:42:50 CDT 2016


On 2016-04-15, 18:58, Stephen Canon wrote:

>> but the documentation for Equatable and Comparable states that == and
>> < must implement an equivalence relation and a strict total order,
>> which is incompatible with the default IEEE-754 implementation of
>> these operators when NaN values are involved. How do you resolve this
>> conflict?
>
> That’s a documentation bug; it should be relaxed by appending something
> like “… on non-exceptional values.”
>
> I’ll quote Dave A. to put it a bit more formally:
>
>> To be clear, the semantic conformance of floating point types to
>> Comparable depends on treating NaN as a "singular value”, i.e. outside
>> the domain of valid arguments to < /for the purposes of Comparable/.
>>  That doesn’t mean we can’t nail down what < does for floating point
>> types when it does get a NaN.

Thanks for the clarification!

- Stephan



More information about the swift-evolution mailing list