<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=""><div class="">Thanks for the feedback, Chris.</div><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 14, 2016, at 9:06 PM, Chris Lattner &lt;<a href="mailto:clattner@apple.com" class="">clattner@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">This proposal looks really really great, let me know when you want to start the review process (or just submit a PR for the -evolution repo) and I’ll happily review manage it for you.</div><div class=""><br class=""></div><div class="">On Apr 14, 2016, at 4:55 PM, Stephen Canon via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><div class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><ul style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class=""><li style="box-sizing: border-box;" class="">Provide basic constants (analogues of C's DBL_MAX, etc.)</li></ul></div></div></blockquote><div class="">Nice, have you considered adding pi/e and other common constants? &nbsp;I’d really really like to see use of M_PI go away… :-)</div></div></div></div></blockquote><div><br class=""></div><div>That’s a reasonable suggestion. &nbsp;I’m not sure if FloatingPoint is the right protocol to attach them to, but I’m not sure that it’s wrong either. &nbsp;I’d be interested to hear arguments from the community either way.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; word-break: normal;" class=""><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// SignedArithmetic protocol will only be conformed to by signed numbers,</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// otherwise it would be possible to negate an unsigned value.</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// The only method of this protocol has the default implementation in an</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// extension, that uses a parameterless initializer and subtraction.</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">protocol</span> SignedArithmetic <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">:</span> Arithmetic {
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">negate</span>() <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> Self
</pre></div></div></div></blockquote><div class="">Should this be negated / negate? &nbsp;negate() seems like an in-place mutating version.</div></div></div></div></blockquote><div><br class=""></div><div>Yup, that seems right.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; word-break: normal;" class=""><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// A floating-point type that provides most of the IEEE 754 basic (clause 5)</span>
</pre></div></div></div></blockquote><div class="">Dumb Q, but is it “IEEE 754” or “IEEE-754”?</div></div></div></div></blockquote><div><br class=""></div><div>It’s commonly styled both ways, but I believe IEEE 754 is the “official" one.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; word-break: normal;" class=""><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// operations.  The base, precision, and exponent range are not fixed in</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// any way by this protocol, but it enforces the basic requirements of</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// any IEEE 754 floating-point type.</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// The BinaryFloatingPoint protocol refines these requirements and provides</span>
<span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// some additional useful operations as well.</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">protocol</span> FloatingPoint: SignedArithmetic, <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Comparable</span> {

  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">static</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> ulp: <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">Self</span> { <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">get</span> }
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> ulp: <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">Self</span> { <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">get</span> }
</pre></div></div></div></blockquote><div class="">Swift supports instance and type members with the same names, but this is controversial, leads to confusion, and may go away in the future. &nbsp;It would be great to avoid this in your design.</div></div></div></div></blockquote><div><br class=""></div><div>Interesting. &nbsp;Both are definitely useful, but Type(1).ulp is sufficiently simple that only having the instance member may be good enough. &nbsp;Otherwise, ulpOfOne or similar could work.</div><div><br class=""></div><div>&lt;snip&gt;</div><div><br class=""></div><blockquote type="cite" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class="">I’m certainly not a floating point guru, but I would have expected significant to be of type&nbsp;RawSignificand, and thought that the significant of a nan would return its payload. &nbsp;Does this approach make sense?</div><div class=""><br class=""></div><div class="">… later: I see that you have this on the binary FP type, so I assume there is a good reason for this :-)</div></div></div></blockquote><div><br class=""></div><div>Both are useful to have in practice. &nbsp;I have been attempting to keep the assumptions about representation to a minimum in the top-level FloatingPoint protocol.</div><div><br class=""></div><div>&lt;snip a few style notes that I’ll simply take as-is because they’re no-brainers&gt;</div><div><br class=""></div><blockquote type="cite" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; padding: 16px; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; word-break: normal;" class="">  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// True if and only if `self` is subnormal.</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">///</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// A subnormal number does not use the full precision available to normal</span>
  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">/// numbers of the same format.  Zero is not a subnormal number.</span>
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> isSubnormal: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Bool</span> { <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">get</span> }
</pre></div></div></div></blockquote><div class="">I’m used to this being called a “Denormal”, but I suspect that “subnormal” is the actually right name? &nbsp;Maybe it would be useful to mention the “frequently known as denormal” in the comment, like you did with mantissa earlier.</div></div></div></blockquote><br class=""></div><div>Yes, “subnormal” is the preferred IEEE 754 terminology, but I’ll add a note referencing “denormal” as well.</div><div><br class=""></div><div>Thanks,</div><div>– Steve</div><div><br class=""></div></body></html>