<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 25, 2017, at 9:34 PM, Jaden Geller &lt;<a href="mailto:jaden.geller@gmail.com" class="">jaden.geller@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><div class=""><br class="Apple-interchange-newline">On Apr 25, 2017, at 8:28 PM, Jonathan Hull via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Apr 25, 2017, at 7:17 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><div class=""><div dir="ltr" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div></div></blockquote><blockquote type="cite" class=""><div dir="ltr" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="gmail_extra"><div class="gmail_quote"><div class="">I'll refer you to Steve Canon's answer on StackOverflow:&nbsp;<a href="http://stackoverflow.com/questions/1565164/what-is-the-rationale-for-all-comparisons-returning-false-for-ieee754-nan-values/1573715#1573715" class="">http://stackoverflow.com/questions/1565164/what-is-the-rationale-for-all-comparisons-returning-false-for-ieee754-nan-values/1573715#1573715</a></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">I get what he is saying about not being able to suddenly change C’s definition to the opposite boolean value (even if they would have designed it differently for modern systems). &nbsp;We aren’t C though. &nbsp;And nil is a different name than NaN. &nbsp;This gives us a way to make a change without breaking conformance.</div></div></div></div></blockquote><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">I really like this idea, but it’s not true to say this doesn’t break IEEE-compliance if what we expose as NaN no longer compares not equal to itself.</div></div></blockquote><div><br class=""></div><div>I would argue that we aren’t actually exposing NaN, so much as we are exposing something which is different, but stays in sync with it. &nbsp;NaN is still there in the format under the surface, but you wouldn’t be able to access it directly (only indirectly).</div><div><br class=""></div><div>It is a bit of a magic trick. &nbsp;Whenever the value is NaN, we only let you access ‘.none’ instead of the value. &nbsp;So, if you were able to directly compare NaN with NaN, it would be false (or unordered), but you can’t get ahold of them to do that comparison.</div><div><br class=""></div><div>The important thing to me is binary compatibility. &nbsp;Algorithms need to be rewritten a bit anyway when moving them into swift, so that isn’t a big deal to write it for nil instead of NaN… especially when the compiler helps you due to the optional. &nbsp;But data, which might contain NaN, needs to be read/written in an interchangeable format. &nbsp;That is why I suggest having Optional do the lifting to match NaN. Anytime it crosses a boundary which strips the wrapper, it will just work (as long as we import as Double?).</div><br class=""><blockquote type="cite" class=""><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><blockquote type="cite" class=""><div dir="ltr" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="gmail_extra"><div class="gmail_quote"><div class="">Bottom line is, whatever it's designed for, it's here to stay. I'm *not* on any IEEE committee; I'm not qualified to design an alternative universe of floating point types; and the Swift evolution mailing list (or even Swift itself) is not the place to design one. I and others rely on Swift floating point types to be IEEE-complaint, so that's where we start the discussion here about Comparable.</div></div></div></div></blockquote><div class=""><br class=""></div><div class="">It *is* IEEE compliant (or at least the same amount we currently are), what is different is the way we interface with that in code. &nbsp;You can think of Swift Double as a simple (runtime-cost-free) wrapper around the compiler’s double that limits how you can touch it (in order to provide additional safety guarantees). &nbsp;Sounds very swifty to me… we do similar things with other C constructs using various wrappers. &nbsp;We aren’t getting rid of NaN behind the scenes, just packaging it’s use in a way which aligns with Swift as a whole… &nbsp;What changes is the programer’s mental model. The bits are exactly the same.</div><div class=""><br class=""></div><div class="">If the naming is what bothers you, we could even just create a “new” Swift type that is this wrapper, and then discourage the use of Double outside of places where NaN is needed. &nbsp;I feel like NaN is actually needed in relatively few places though…</div><div class=""><br class=""></div><blockquote type="cite" class=""><div dir="ltr" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="gmail_extra"><div class="gmail_quote"><div class="">&nbsp;</div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class="" style="word-wrap: break-word;"><div class=""><div class=""></div><div class="">The programmer (mental) model would be that Swift Double just doesn’t have NaN, and anywhere where you would normally return NaN, you return nil instead.</div></div></div></blockquote><div class=""><br class=""></div><div class="">Look, you can already use Double? today. There is no barrier to trying it out for yourself. However, `Double?.none` doesn't mean the same thing as `Double.nan`. The former indicates that _there is no value_; the latter indicates that there _is_ a value, it's just _not a number_. Suppose I parse a list of numbers into an array. If I ask for [Double].last and get nil, it's telling me that _there are no elements in the array_. If I get .nan, it's telling me that there *is* a value, it just wasn't a number. In the former case, I'd do nothing. In the latter case, I might prompt the user: this isn't a number!</div><div class="">&nbsp;</div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class="" style="word-wrap: break-word;"><div class=""><div class="">However, the property of using NaN’s bits to represent nil let’s us inter-op seamlessly with C and ObjC (or any other language’s) code.&nbsp; They just treat it as a double with NaN as normal (including NaN != NaN) and we interface with it as ‘Double?'</div></div></div></blockquote><div class=""><br class=""></div><div class="">I'm going to sound like a broken record, now. Whether floating point types in Swift conform to IEEE standards is _not_ up for discussion, afaict; that's simply a given. Now, around that constraint, we're trying to design a revised Comparable protocol. Code written today for floating point work expects NaN != NaN. That is just something that is and will forever be. We break source compatibility if we change that.</div></div></div></div></blockquote><div class=""><br class=""></div><div class="">As I said above, they *do* conform to those standards… they just don’t expose the full capabilities directly to the end programmer. &nbsp;The capabilities are still there, you just have to be more explicit about their use. &nbsp;</div><div class=""><br class=""></div><div class="">I could be wrong, but I believe that in the current version of Swift, the result of doing comparisons with NaN is actually undefined at the moment… so it isn’t breaking source compatibility with the defined language. &nbsp;Just with code which is using implementation artifacts…</div></div></div></div></blockquote><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">I think you’re incorrect. It says in the docs for NaN that it always compares false with itself.</div></blockquote><div><br class=""></div><div>That’s too bad. I was looking in the language guide. &nbsp;I guess it would be a breaking change to change Float/Double. &nbsp;We could still use the idea though, we would just have to add the wrapper as a new type with a different name. &nbsp;</div><div><br class=""></div><div>I would be in favor of renaming Float/Double to something like CFloat/CDouble, and then reusing the names for the wrappers. Not sure if I could convince the powers that be of that though…</div><div><br class=""></div><div>I am not sure how much code actually uses NaN in this way in the real world. &nbsp;</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="">C code might require some simple changes to work in Swift, but as you argued passionately before, that is already to be expected. &nbsp;We shouldn’t have the expectation of copy/pasting C code without thinking through the differences in &amp;+, etc...</div><br class=""><blockquote type="cite" class=""><div dir="ltr" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class="" style="word-wrap: break-word;"><div class=""><span class="gmail-"><div class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">This did not always work correctly, if I recall, but it does now and it's an intentional part of the design. However, NaN must compare not equal to every NaN. These could not be more different properties. It seems quite absurd on its face that we might want NaN to compare equal to a value of type `Optional&lt;UIViewController&gt;`.<br class=""></div></div></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">Is there an algorithm that requires NaN != NaN that couldn’t be reasonably rewritten to handle nil/optionals instead?&nbsp;</div></div></div></blockquote><div class=""><br class=""></div><div class="">I don't need an algorithm to show you the problem. See this expression: `0 * Double.infinity == .infinity * 0` correctly evaluates to false. Zero times infinity is simply not equal to infinity times zero. You're suggesting a design where the result would be true, and that simply won't fly, because it's just not true.</div></div></div></div></blockquote><div class=""><br class=""></div><div class="">IEEE 754 says that the result of any comparison with NaN should be *undefined*. &nbsp;C’s implementation is the one who brings us this idea that NaN != NaN. &nbsp;The *correct* evaluation according to 754 would be ‘undefined’. &nbsp;We aren’t breaking 754, just breaking away from a C convention… in a way which is very much in line with how Swift breaks away from other C conventions.</div></div></div></div></blockquote><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">I don’t think this is true. I got excited for a minute and looked it up. Where do you see that comparison behavior is undefined?</div></blockquote><div><br class=""></div><div>Oh, sorry, I didn’t mean that the behavior is undefined… &nbsp;I used the wrong word (freudian slip). &nbsp;I meant to say that the correct evaluation is *unordered*. &nbsp;Four possibilities are defined in the spec: GreaterThan, LessThan, Equal, and Unordered. &nbsp;NaN is always unordered when compared with anything.</div><div><br class=""></div><div>From the spec:</div><div><blockquote type="cite" class=""><span style="font-size: 10pt; font-family: TimesNewRomanPSMT;" class="">For every supported arithmetic format, it shall be possible to compare one floating-point datum to another
in that format (see </span><span style="font-size: 10pt; font-family: TimesNewRomanPSMT; color: rgb(0, 0, 255);" class="">5.6.1</span><span style="font-size: 10pt; font-family: TimesNewRomanPSMT;" class="">). Additionally, floating-point data represented in different formats shall be
comparable as long as the operands’ formats have the same radix.</span></blockquote><blockquote type="cite">

        
                
                
        
        
                <div class="page" title="Page 41">
                        <div class="layoutArea">
                                <div class="column"><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">Four mutually exclusive relations are possible: </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">less than</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">, </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">equal</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">, </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">greater than</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">, and </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">unordered</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">. The last case
arises when at least one operand is NaN. Every NaN shall compare </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">unordered </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">with everything, including
itself. Comparisons shall ignore the sign of zero (so +0 = </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">−</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">0). Infinite operands of the same sign shall
compare </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">equal</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">.
</span></p></div></div></div></blockquote><div><br class=""></div><div><br class=""></div>And as I read further, It does appear I was wrong about NaN != NaN (when doing a partial order). &nbsp;I had somehow missed it in my first read-through &nbsp;In the 2008 version of the spec, it goes on to say:<br class=""><blockquote type="cite"><div class="page" title="Page 41"><div class="layoutArea"><div class="column"><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">Languages define how the result of a comparison shall be delivered, in one of two ways: either as a relation
identifying one of the four relations listed above, or as a true-false response to a predicate that names the
specific comparison desired.</span></p></div></div></div></blockquote><div>Which means that we should have 4 functions: ==, &lt;, &gt;, and isUnordered… where isUnordered is the only one which returns true for NaN</div><div><br class=""></div><div>One loophole is that it gives alternate names for those functions which we could use for the official behavior (and still use &lt; and == for our strict total order):</div><div>•&nbsp;compareQuietEqual</div><div>•&nbsp;compareQuietGreater</div><div>•&nbsp;compareQuietLess</div><div>•&nbsp;compareQuietUnordered</div><div><br class=""></div><div>Also, we should all read section 5.10, as it seems to give a canonical answer of how to do a total order for 754:</div><div><blockquote type="cite" class="">

        
                
                
        
        
                <div class="page" title="Page 40">
                        <div class="layoutArea">
                                <div class="column"><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">totalOrder(</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x, y</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">) imposes a total ordering on canonical members of the format of </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">and </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">y</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">:
</span></p>
                                        <ol style="list-style-type: none" class="">
                                                <li class=""><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">a) &nbsp;If </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">&lt; </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">y</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">, totalOrder(</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x, y</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">) is true.
</span></p>
                                                </li>
                                                <li class=""><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">b) &nbsp;If </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">&gt; </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">y</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">, totalOrder(</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x, y</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">) is false.
</span></p>
                                                </li>
                                                <li class=""><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">c) &nbsp;If</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">=</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">y</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">:
</span></p>
                                                        <ol style="list-style-type: none" class="">
                                                                <li class=""><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">1) &nbsp;totalOrder(</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">−</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">0, +0) is true.
</span></p>
                                                                </li>
                                                                <li class=""><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">2) &nbsp;totalOrder(+0, </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">−</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">0) is false.
</span></p>
                                                                </li>
                                                                <li class=""><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">3) &nbsp;If </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">and </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">y </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">represent the same floating-point datum:
</span></p>
                                                                </li>
                                                        </ol>
                                                </li>
                                        </ol><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">i) If </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">and </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">y </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">have negative sign,<br class="">
totalOrder(</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">, </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">y</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">) is true if and only if the exponent of </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">≥ </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">the exponent of </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">y
</span></p><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">ii) otherwise<br class="">
totalOrder(</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">, </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">y</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">) is true if and only if the exponent of </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">≤ </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">the exponent of </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">y.
</span></p><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">d) If </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">and </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">y </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">are unordered numerically because </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">or </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">y </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">is NaN:
</span></p>
                                        <ol style="list-style-type: none" class="">
                                                <li class=""><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">1) &nbsp;totalOrder(</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">−</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">NaN, </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">y</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">) is true where </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">−</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">NaN represents a NaN with negative sign bit and </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">y </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">is a
</span></p><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">floating-point number.
</span></p>
                                                </li>
                                                <li class=""><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">2) &nbsp;totalOrder(</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">, +NaN) is true where +NaN represents a NaN with positive sign bit and </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">is a
floating-point number.
</span></p>
                                                </li>
                                                <li class=""><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">3) &nbsp;If </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">and </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">y </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">are both NaNs, then totalOrder reflects a total ordering based on:
</span></p>
                                                        <ol style="list-style-type: none" class="">
                                                                <li class=""><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">i) &nbsp;negative sign orders below positive sign
</span></p>
                                                                </li>
                                                                <li class=""><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">ii) &nbsp;signaling orders below quiet for +NaN, reverse for </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">−</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">NaN
</span></p>
                                                                </li>
                                                        </ol><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">iii) lesser payload, when regarded as an integer, orders below greater payload for +NaN,
reverse for </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">−</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">NaN.
</span></p>
                                                </li>
                                        </ol><p class=""><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">Neither signaling NaNs nor quiet NaNs signal an exception. For canonical </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">and </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">y</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">, totalOrder(</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x, y</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">) and
totalOrder( </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">y, x</span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">) are both true if </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">x </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">and </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPS'; font-style: italic" class="">y </span><span style="font-size: 10.000000pt; font-family: 'TimesNewRomanPSMT'" class="">are bitwise identical.&nbsp;</span></p>
                                </div>
                        </div>
                </div></blockquote></div><div>Here we see NaN == NaN when doing a total order (as long as the payloads are the same).</div><div><br class=""></div><div>Thanks,</div><div>Jon</div><div><br class=""></div><div><br class=""></div><div><br class=""></div><div><br class=""></div><div><br class=""></div><div><br class=""></div><div><br class=""></div></div></div></body></html>