[swift-evolution] [Idea] Bringing the partial/total ordering distinction into Comparable
Dave Abrahams
dabrahams at apple.com
Mon Apr 25 17:41:15 CDT 2016
on Mon Apr 25 2016, Stephen Canon <swift-evolution at swift.org> wrote:
> On Apr 24, 2016, at 6:08 PM, Xiaodi Wu via swift-evolution
> <swift-evolution at swift.org> wrote:
>
> Something else to consider if you insist that all floating point values must
> be "orderable" would be how two NaNs are ordered if they have different
> payloads. As far as I'm aware, that goes beyond what IEEE 754 has to say
> about total ordering of floating point values.
>
> The IEEE 754 totalOrder predicate is an honest-to-god total order on all
> canonical members of a format (this includes ordering all NaNs by sign,
> signalingness, and payload).
And that, almost by itself, is enough justification for us to use this
ordering for the result of <=> on floats. The fact that this ordering
is consistent with the results of < (for values that are ordered with
respect to <) is a bonus.
--
Dave
More information about the swift-evolution
mailing list