<div dir="ltr">+1 great addition.<div><br></div><div>Would suggest the naming could be more consistent, in particular:</div><div><ol><li>Anything returning Self could be named xxxed. In the current proposal this naming convention is sometimes used, e.g. divided, and sometimes not, e.g. subtracting. Suggest all unified with the xxxed convention.<br></li><li>Anything returning Bool could be named isXxx. In some cases this is used, e.g. isUnordered, but not others, e.g. totalOrder.</li></ol></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature">  -- Howard.<br></div></div>
<br><div class="gmail_quote">On 15 April 2016 at 09:55, Stephen Canon via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><h1 style="font-size:2.25em;margin-right:0px;margin-bottom:16px;margin-left:0px;line-height:1.2;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255);margin-top:0px!important">Enhanced floating-point protocols</h1><ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><li>Proposal: <a href="https://github.com/apple/swift-evolution/blob/master/proposals/NNNN-name.md" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">SE-NNNN</a></li><li>Author(s): <a href="https://github.com/stephentyrone" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">Stephen Canon</a></li><li>Status: <strong>Awaiting review</strong></li><li>Review manager: TBD</li></ul><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://github.com/stephentyrone/swift-evolution/blob/master/NNNN-floating-point-protocols.md#introduction" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Introduction</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">The current FloatingPoint protocol is quite limited, and provides only a small subset of the features expected of an IEEE 754 conforming type. This proposal expands the protocol to cover most of the expected basic operations, and adds a second protocol, BinaryFloatingPoint, that provides a number of useful tools for generic programming with the most commonly used types.</p><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://github.com/stephentyrone/swift-evolution/blob/master/NNNN-floating-point-protocols.md#motivation" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Motivation</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Beside the high-level motivation provided by the introduction, the proposed prototype schema addresses a number of issues and requests that we&#39;ve received from programmers:</p><ul style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><li>FloatingPoint should conform to Equatable, and Comparable</li><li>FloatingPoint should conform to FloatLiteralConvertible</li><li>Deprecate the <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">%</code> operator for floating-point types</li><li>Provide basic constants (analogues of C&#39;s DBL_MAX, etc.)</li><li>Make Float80 conform to FloatingPoint</li></ul><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">It also puts FloatingPoint much more tightly in sync with the work that is being done on protocols for Integers, which will make it easier to provide a uniform interface for arithmetic scalar types.</p><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://github.com/stephentyrone/swift-evolution/blob/master/NNNN-floating-point-protocols.md#detailed-design" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Detailed design</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">A new protocol, <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Arithmetic</code>, is introduced that provides the most basic operations (add, subtract, multiply and divide) as well as <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Equatable</code> and <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">IntegerLiteralConvertible</code>, and is conformed to by both integer and floating- point types.</p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">There has been some resistance to adding such a protocol, owing to differences in behavior between floating point and integer arithmetic. While these differences make it difficult to write correct generic code that operates on all &quot;arithmetic&quot; types, it is nonetheless convenient to provide a single protocol that guarantees the availability of these basic operations. It is intended that &quot;number-like&quot; types should provide these APIs.</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,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"><span style="color:rgb(150,152,150)">/// Arithmetic protocol declares methods backing binary arithmetic operators,</span>
<span style="color:rgb(150,152,150)">/// such as  `+`, `-` and `*`; and their mutating counterparts.  These methods</span>
<span style="color:rgb(150,152,150)">/// operate on arguments of the same type.</span>
<span style="color:rgb(150,152,150)">///</span>
<span style="color:rgb(150,152,150)">/// Both mutating and non-mutating operations are declared in the protocol, but</span>
<span style="color:rgb(150,152,150)">/// only the mutating ones are required.  Should conforming type omit</span>
<span style="color:rgb(150,152,150)">/// non-mutating implementations, they will be provided by a protocol extension.</span>
<span style="color:rgb(150,152,150)">/// Implementation in that case will copy `self`, perform a mutating operation</span>
<span style="color:rgb(150,152,150)">/// on it and return the resulting value.</span>
<span style="color:rgb(167,29,93)">public</span> <span style="color:rgb(167,29,93)">protocol</span> Arithmetic: <span style="color:rgb(0,134,179)">Equatable</span>, <span style="color:rgb(0,134,179)">IntegerLiteralConvertible</span> {
  <span style="color:rgb(150,152,150)">/// Initialize to zero</span>
  <span style="color:rgb(167,29,93)">init</span>()

  <span style="color:rgb(150,152,150)">/// The sum of `self` and `rhs`.</span>
  <span style="color:rgb(150,152,150)">//  Arithmetic provides a default implementation of this method in terms</span>
  <span style="color:rgb(150,152,150)">//  of the mutating `add` operation.</span>
  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">adding</span>(rhs: <span style="color:rgb(167,29,93)">Self</span>) <span style="color:rgb(167,29,93)">-&gt;</span> Self

  <span style="color:rgb(150,152,150)">/// Adds `rhs` to `self`.</span>
  <span style="color:rgb(167,29,93)">mutating</span> <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">add</span>(rhs: <span style="color:rgb(167,29,93)">Self</span>)

  <span style="color:rgb(150,152,150)">/// The result of subtracting `rhs` from `self`.</span>
  <span style="color:rgb(150,152,150)">//  Arithmetic provides a default implementation of this method in terms</span>
  <span style="color:rgb(150,152,150)">//  of the mutating `subtract` operation.</span>
  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">subtracting</span>(rhs: <span style="color:rgb(167,29,93)">Self</span>) <span style="color:rgb(167,29,93)">-&gt;</span> Self

  <span style="color:rgb(150,152,150)">/// Subtracts `rhs` from `self`.</span>
  <span style="color:rgb(167,29,93)">mutating</span> <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">subtract</span>(rhs: <span style="color:rgb(167,29,93)">Self</span>)

  <span style="color:rgb(150,152,150)">/// The product of `self` and `rhs`.</span>
  <span style="color:rgb(150,152,150)">//  Arithmetic provides a default implementation of this method in terms</span>
  <span style="color:rgb(150,152,150)">//  of the mutating `multiply` operation.</span>
  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">multiplied</span>(<span style="color:rgb(121,93,163)">by</span> <span>rhs</span>: <span style="color:rgb(167,29,93)">Self</span>) <span style="color:rgb(167,29,93)">-&gt;</span> Self

  <span style="color:rgb(150,152,150)">/// Multiplies `self` by `rhs`.</span>
  <span style="color:rgb(167,29,93)">mutating</span> <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">multiply</span>(<span style="color:rgb(121,93,163)">by</span> <span>rhs</span>: <span style="color:rgb(167,29,93)">Self</span>)

  <span style="color:rgb(150,152,150)">/// The quotient of `self` dividing by `rhs`.</span>
  <span style="color:rgb(150,152,150)">//  Arithmetic provides a default implementation of this method in terms</span>
  <span style="color:rgb(150,152,150)">//  of the mutating `divide` operation.</span>
  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">divided</span>(<span style="color:rgb(121,93,163)">by</span> <span>rhs</span>: <span style="color:rgb(167,29,93)">Self</span>) <span style="color:rgb(167,29,93)">-&gt;</span> Self

  <span style="color:rgb(150,152,150)">/// Divides `self` by `rhs`.</span>
  <span style="color:rgb(167,29,93)">mutating</span> <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">divide</span>(<span style="color:rgb(121,93,163)">by</span> <span>rhs</span>: <span style="color:rgb(167,29,93)">Self</span>)
}

<span style="color:rgb(150,152,150)">/// SignedArithmetic protocol will only be conformed to by signed numbers,</span>
<span style="color:rgb(150,152,150)">/// otherwise it would be possible to negate an unsigned value.</span>
<span style="color:rgb(150,152,150)">///</span>
<span style="color:rgb(150,152,150)">/// The only method of this protocol has the default implementation in an</span>
<span style="color:rgb(150,152,150)">/// extension, that uses a parameterless initializer and subtraction.</span>
<span style="color:rgb(167,29,93)">public</span> <span style="color:rgb(167,29,93)">protocol</span> SignedArithmetic <span style="color:rgb(167,29,93)">:</span> Arithmetic {
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">negate</span>() <span style="color:rgb(167,29,93)">-&gt;</span> Self
}</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">The usual arithmetic operators are then defined in terms of the implementation hooks provided by <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Arithmetic</code> and <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">SignedArithmetic</code>, so providing those operations are all that is necessary for a type to present a &quot;number-like&quot; interface.</p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">The <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">FloatingPoint</code> protocol is split into two parts; <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">FloatingPoint</code> and <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">BinaryFloatingPoint</code>, which conforms to <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">FloatingPoint</code>. If decimal types were added at some future point, they would conform to <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">DecimalFloatingPoint</code>.</p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">FloatingPoint</code> is expanded to contain most of the IEEE 754 basic operations, as well as conformance to <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">SignedArithmetic</code> and <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Comparable</code>.</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,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"><span style="color:rgb(150,152,150)">/// A floating-point type that provides most of the IEEE 754 basic (clause 5)</span>
<span style="color:rgb(150,152,150)">/// operations.  The base, precision, and exponent range are not fixed in</span>
<span style="color:rgb(150,152,150)">/// any way by this protocol, but it enforces the basic requirements of</span>
<span style="color:rgb(150,152,150)">/// any IEEE 754 floating-point type.</span>
<span style="color:rgb(150,152,150)">///</span>
<span style="color:rgb(150,152,150)">/// The BinaryFloatingPoint protocol refines these requirements and provides</span>
<span style="color:rgb(150,152,150)">/// some additional useful operations as well.</span>
<span style="color:rgb(167,29,93)">public</span> <span style="color:rgb(167,29,93)">protocol</span> FloatingPoint: SignedArithmetic, <span style="color:rgb(0,134,179)">Comparable</span> {

  <span style="color:rgb(150,152,150)">/// An unsigned integer type that can represent the significand of any value.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// The significand (<a href="http://en.wikipedia.org/wiki/Significand" target="_blank">http://en.wikipedia.org/wiki/Significand</a>) is frequently</span>
  <span style="color:rgb(150,152,150)">/// also called the &quot;mantissa&quot;, but this terminology is slightly incorrect</span>
  <span style="color:rgb(150,152,150)">/// (see the &quot;Use of &#39;mantissa&#39;&quot; section on the linked Wikipedia page for</span>
  <span style="color:rgb(150,152,150)">/// more details).  &quot;Significand&quot; is the preferred terminology in IEEE 754.</span>
  associatedtype RawSignificand: UnsignedInteger

  <span style="color:rgb(150,152,150)">/// 2 for binary floating-point types, 10 for decimal.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// A conforming type may use any integer radix, but values other than</span>
  <span style="color:rgb(150,152,150)">/// 2 or 10 are extraordinarily rare in practice.</span>
  <span style="color:rgb(167,29,93)">static</span> <span style="color:rgb(167,29,93)">var</span> radix: <span style="color:rgb(0,134,179)">Int</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// Positive infinity.  Compares greater than all finite numbers.</span>
  <span style="color:rgb(167,29,93)">static</span> <span style="color:rgb(167,29,93)">var</span> infinity: <span style="color:rgb(167,29,93)">Self</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// A quiet NaN (not-a-number).  Compares not equal to every value,</span>
  <span style="color:rgb(150,152,150)">/// including itself.</span>
  <span style="color:rgb(167,29,93)">static</span> <span style="color:rgb(167,29,93)">var</span> nan: <span style="color:rgb(167,29,93)">Self</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// NaN with specified `payload`.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// Compares not equal to every value, including itself.  Most operations</span>
  <span style="color:rgb(150,152,150)">/// with a NaN operand will produce a NaN result.  Note that it is generally</span>
  <span style="color:rgb(150,152,150)">/// not the case that all possible significand values are valid</span>
  <span style="color:rgb(150,152,150)">/// NaN `payloads`.  `FloatingPoint` types should either treat inadmissible</span>
  <span style="color:rgb(150,152,150)">/// payloads as zero, or mask them to create an admissible payload.</span>
  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">static</span> <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">nan</span>(<span style="color:rgb(121,93,163)">payload</span> <span>payload</span>: RawSignificand, signaling: <span style="color:rgb(0,134,179)">Bool</span>) <span style="color:rgb(167,29,93)">-&gt;</span> Self

  <span style="color:rgb(150,152,150)">/// The greatest finite number.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// Compares greater than or equal to all finite numbers, but less than</span>
  <span style="color:rgb(150,152,150)">/// infinity.  Corresponds to the C macros `FLT_MAX`, `DBL_MAX`, etc.</span>
  <span style="color:rgb(150,152,150)">/// The naming of those macros is slightly misleading, because infinity</span>
  <span style="color:rgb(150,152,150)">/// is greater than this value.</span>
  <span style="color:rgb(167,29,93)">static</span> <span style="color:rgb(167,29,93)">var</span> greatestFiniteMagnitude: <span style="color:rgb(167,29,93)">Self</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">// NOTE: Rationale for &quot;ulp&quot; instead of &quot;epsilon&quot;:</span>
  <span style="color:rgb(150,152,150)">// We do not use that name because it is ambiguous at best and misleading</span>
  <span style="color:rgb(150,152,150)">// at worst:</span>
  <span style="color:rgb(150,152,150)">//</span>
  <span style="color:rgb(150,152,150)">// - Historically several definitions of &quot;machine epsilon&quot; have commonly</span>
  <span style="color:rgb(150,152,150)">//   been used, which differ by up to a factor of two or so.  By contrast</span>
  <span style="color:rgb(150,152,150)">//   &quot;ulp&quot; is a term with a specific unambiguous definition.</span>
  <span style="color:rgb(150,152,150)">//</span>
  <span style="color:rgb(150,152,150)">// - Some languages have used &quot;epsilon&quot; to refer to wildly different values,</span>
  <span style="color:rgb(150,152,150)">//   such as `leastMagnitude`.</span>
  <span style="color:rgb(150,152,150)">//</span>
  <span style="color:rgb(150,152,150)">// - Inexperienced users often believe that &quot;epsilon&quot; should be used as a</span>
  <span style="color:rgb(150,152,150)">//   tolerance for floating-point comparisons, because of the name.  It is</span>
  <span style="color:rgb(150,152,150)">//   nearly always the wrong value to use for this purpose.</span>

  <span style="color:rgb(150,152,150)">/// The unit in the last place of 1.0.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// This is the weight of the least significant bit of the significand of 1.0,</span>
  <span style="color:rgb(150,152,150)">/// or the positive difference between 1.0 and the next greater representable</span>
  <span style="color:rgb(150,152,150)">/// number.  Corresponds to the C macros `FLT_EPSILON`, `DBL_EPSILON`, etc.</span>
  <span style="color:rgb(167,29,93)">static</span> <span style="color:rgb(167,29,93)">var</span> ulp: <span style="color:rgb(167,29,93)">Self</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// The unit in the last place of `self`.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// This is the unit of the least significant digit in the significand of</span>
  <span style="color:rgb(150,152,150)">/// `self`.  For most numbers `x`, this is the difference between `x` and</span>
  <span style="color:rgb(150,152,150)">/// the next greater (in magnitude) representable number.  There are some</span>
  <span style="color:rgb(150,152,150)">/// edge cases to be aware of:</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// - `greatestFiniteMagnitude.ulp` is a finite number, even though</span>
  <span style="color:rgb(150,152,150)">///   the next greater representable value is `infinity`.</span>
  <span style="color:rgb(150,152,150)">/// - `x.ulp` is `NaN` if `x` is not a finite number.</span>
  <span style="color:rgb(150,152,150)">/// - If `x` is very small in magnitude, then `x.ulp` may be a subnormal</span>
  <span style="color:rgb(150,152,150)">///   number.  On targets that do not support subnormals, `x.ulp` may be</span>
  <span style="color:rgb(150,152,150)">///   flushed to zero.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// This quantity, or a related quantity is sometimes called &quot;epsilon&quot; or</span>
  <span style="color:rgb(150,152,150)">/// &quot;machine epsilon&quot;.  We avoid that name because it has different meanings</span>
  <span style="color:rgb(150,152,150)">/// in different languages, which can lead to confusion, and because it</span>
  <span style="color:rgb(150,152,150)">/// suggests that it is an good tolerance to use for comparisons,</span>
  <span style="color:rgb(150,152,150)">/// which is almost never is.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// (See <a href="https://en.wikipedia.org/wiki/Machine_epsilon" target="_blank">https://en.wikipedia.org/wiki/Machine_epsilon</a> for more detail)</span>
  <span style="color:rgb(167,29,93)">var</span> ulp: <span style="color:rgb(167,29,93)">Self</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// The least positive normal number.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// Compares less than or equal to all positive normal numbers.  There may</span>
  <span style="color:rgb(150,152,150)">/// be smaller positive numbers, but they are &quot;subnormal&quot;, meaning that</span>
  <span style="color:rgb(150,152,150)">/// they are represented with less precision than normal numbers.</span>
  <span style="color:rgb(150,152,150)">/// Corresponds to the C macros `FLT_MIN`, `DBL_MIN`, etc.  The naming of</span>
  <span style="color:rgb(150,152,150)">/// those macros is slightly misleading, because subnormals, zeros, and</span>
  <span style="color:rgb(150,152,150)">/// negative numbers are smaller than this value.</span>
  <span style="color:rgb(167,29,93)">static</span> <span style="color:rgb(167,29,93)">var</span> leastNormalMagnitude: <span style="color:rgb(167,29,93)">Self</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// The least positive number.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// Compares less than or equal to all positive numbers, but greater than</span>
  <span style="color:rgb(150,152,150)">/// zero.  If the target supports subnormal values, this is smaller than</span>
  <span style="color:rgb(150,152,150)">/// `leastNormalMagnitude`; otherwise they are equal.</span>
  <span style="color:rgb(167,29,93)">static</span> <span style="color:rgb(167,29,93)">var</span> leastMagnitude: <span style="color:rgb(167,29,93)">Self</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// `true` iff the signbit of `self` is set.  Implements the IEEE 754</span>
  <span style="color:rgb(150,152,150)">/// `signbit` operation.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// Note that this is not the same as `self &lt; 0`.  In particular, this</span>
  <span style="color:rgb(150,152,150)">/// property is true for `-0` and some NaNs, both of which compare not</span>
  <span style="color:rgb(150,152,150)">/// less than zero.</span>
  <span style="color:rgb(150,152,150)">//  TODO: strictly speaking a bit and a bool are slightly different</span>
  <span style="color:rgb(150,152,150)">//  concepts.  Is another name more appropriate for this property?</span>
  <span style="color:rgb(150,152,150)">//  `isNegative` is incorrect because of -0 and NaN.  `isSignMinus` might</span>
  <span style="color:rgb(150,152,150)">//  be acceptable, but isn&#39;t great.  `signBit` is the IEEE 754 name.</span>
  <span style="color:rgb(167,29,93)">var</span> signBit: <span style="color:rgb(0,134,179)">Bool</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// The integer part of the base-r logarithm of the magnitude of `self`,</span>
  <span style="color:rgb(150,152,150)">/// where r is the radix (2 for binary, 10 for decimal).  Implements the</span>
  <span style="color:rgb(150,152,150)">/// IEEE 754 `logB` operation.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// Edge cases:</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// - If `x` is zero, then `x.exponent` is `Int.min`.</span>
  <span style="color:rgb(150,152,150)">/// - If `x` is +/-infinity or NaN, then `x.exponent` is `Int.max`</span>
  <span style="color:rgb(167,29,93)">var</span> exponent: <span style="color:rgb(0,134,179)">Int</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// The significand satisfies:</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// ~~~</span>
  <span style="color:rgb(150,152,150)">/// self = (signBit ? -1 : 1) * significand * radix**exponent</span>
  <span style="color:rgb(150,152,150)">/// ~~~</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// If radix is 2 (the most common case), then for finite non-zero numbers</span>
  <span style="color:rgb(150,152,150)">/// `1 &lt;= significand` and `significand &lt; 2`.  For other values of `x`,</span>
  <span style="color:rgb(150,152,150)">/// `x.significand` is defined as follows:</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// - If `x` is zero, then `x.significand` is 0.0.</span>
  <span style="color:rgb(150,152,150)">/// - If `x` is infinity, then `x.significand` is 1.0.</span>
  <span style="color:rgb(150,152,150)">/// - If `x` is NaN, then `x.significand` is NaN.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// For all floating-point `x`, if we define y by:</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// ~~~</span>
  <span style="color:rgb(150,152,150)">/// let y = Self(signBit: x.signBit, exponent: x.exponent,</span>
  <span style="color:rgb(150,152,150)">///              significand: x.significand)</span>
  <span style="color:rgb(150,152,150)">/// ~~~</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// then `y` is equivalent to `x`, meaning that `y` is `x` canonicalized.</span>
  <span style="color:rgb(167,29,93)">var</span> significand: <span style="color:rgb(167,29,93)">Self</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// Initialize from signBit, exponent, and significand.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// The result is:</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// ~~~</span>
  <span style="color:rgb(150,152,150)">/// (signBit ? -1 : 1) * significand * radix**exponent</span>
  <span style="color:rgb(150,152,150)">/// ~~~</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// (where `**` is exponentiation) computed as if by a single correctly-</span>
  <span style="color:rgb(150,152,150)">/// rounded floating-point operation.  If this value is outside the</span>
  <span style="color:rgb(150,152,150)">/// representable range of the type, overflow or underflow occurs, and zero,</span>
  <span style="color:rgb(150,152,150)">/// a subnormal value, or infinity may result, as with any basic operation.</span>
  <span style="color:rgb(150,152,150)">/// Other edge cases:</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// - If `significand` is zero or infinite, the result is zero or infinite,</span>
  <span style="color:rgb(150,152,150)">///   regardless of the value of `exponent`.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// - If `significand` is NaN, the result is NaN.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// Note that for any floating-point `x` the result of</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">///   `Self(signBit: x.signBit,</span>
  <span style="color:rgb(150,152,150)">///         exponent: x.exponent,</span>
  <span style="color:rgb(150,152,150)">///         significand: x.significand)`</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// is &quot;the same&quot; as `x`; it is `x` canonicalized.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// Because of these properties, this initializer implements the IEEE 754</span>
  <span style="color:rgb(150,152,150)">/// `scaleB` operation.</span>
  <span style="color:rgb(167,29,93)">init</span>(signBit: <span style="color:rgb(0,134,179)">Bool</span>, exponent: <span style="color:rgb(0,134,179)">Int</span>, significand: <span style="color:rgb(167,29,93)">Self</span>)

  <span style="color:rgb(150,152,150)">/// A floating point value whose exponent and signficand are taken from</span>
  <span style="color:rgb(150,152,150)">/// `magnitude` and whose signBit is taken from `signOf`.  Implements the</span>
  <span style="color:rgb(150,152,150)">/// IEEE 754 `copysign` operation.</span>
  <span style="color:rgb(150,152,150)">//  TODO: better argument names would be great.</span>
  <span style="color:rgb(167,29,93)">init</span>(magnitudeOf magnitude: <span style="color:rgb(167,29,93)">Self</span>, signOf: <span style="color:rgb(167,29,93)">Self</span>)

  <span style="color:rgb(150,152,150)">/// The least representable value that compares greater than `self`.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// - If `x` is `-infinity`, then `x.nextUp` is `-greatestMagnitude`.</span>
  <span style="color:rgb(150,152,150)">/// - If `x` is `-leastMagnitude`, then `x.nextUp` is `-0.0`.</span>
  <span style="color:rgb(150,152,150)">/// - If `x` is zero, then `x.nextUp` is `leastMagnitude`.</span>
  <span style="color:rgb(150,152,150)">/// - If `x` is `greatestMagnitude`, then `x.nextUp` is `infinity`.</span>
  <span style="color:rgb(150,152,150)">/// - If `x` is `infinity` or `NaN`, then `x.nextUp` is `x`.</span>
  <span style="color:rgb(167,29,93)">var</span> nextUp: <span style="color:rgb(167,29,93)">Self</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// The greatest representable value that compares less than `self`.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// `x.nextDown` is equivalent to `-(-x).nextUp`</span>
  <span style="color:rgb(167,29,93)">var</span> nextDown: <span style="color:rgb(167,29,93)">Self</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// Remainder of `self` divided by `other`.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// For finite `self` and `other`, the remainder `r` is defined by</span>
  <span style="color:rgb(150,152,150)">/// `r = self - other*n`, where `n` is the integer nearest to `self/other`.</span>
  <span style="color:rgb(150,152,150)">/// (Note that `n` is *not* `self/other` computed in floating-point</span>
  <span style="color:rgb(150,152,150)">/// arithmetic, and that `n` may not even be representable in any available</span>
  <span style="color:rgb(150,152,150)">/// integer type).  If `self/other` is exactly halfway between two integers,</span>
  <span style="color:rgb(150,152,150)">/// `n` is chosen to be even.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// It follows that if `self` and `other` are finite numbers, the remainder</span>
  <span style="color:rgb(150,152,150)">/// `r` satisfies `-|other|/2 &lt;= r` and `r &lt;= |other|/2`.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// `formRemainder` is always exact, and therefore is not affected by</span>
  <span style="color:rgb(150,152,150)">/// rounding modes.</span>
  <span style="color:rgb(167,29,93)">mutating</span> <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">formRemainder</span>(<span style="color:rgb(121,93,163)">dividingBy</span> <span>other</span>: <span style="color:rgb(167,29,93)">Self</span>)

  <span style="color:rgb(150,152,150)">/// Remainder of `self` divided by `other` using truncating division.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// If `self` and `other` are finite numbers, the truncating remainder</span>
  <span style="color:rgb(150,152,150)">/// `r` has the same sign as `other` and is strictly smaller in magnitude.</span>
  <span style="color:rgb(150,152,150)">/// It satisfies `r = self - other*n`, where `n` is the integral part</span>
  <span style="color:rgb(150,152,150)">/// of `self/other`.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// `formTruncatingRemainder` is always exact, and therefore is not</span>
  <span style="color:rgb(150,152,150)">/// affected by rounding modes.</span>
  <span style="color:rgb(167,29,93)">mutating</span> <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">formTruncatingRemainder</span>(<span style="color:rgb(121,93,163)">dividingBy</span> <span>other</span>: <span style="color:rgb(167,29,93)">Self</span>)

  <span style="color:rgb(150,152,150)">/// Mutating form of square root.</span>
  <span style="color:rgb(167,29,93)">mutating</span> <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">formSquareRoot</span>( )

  <span style="color:rgb(150,152,150)">/// Fused multiply-add, accumulating the product of `lhs` and `rhs` to `self`.</span>
  <span style="color:rgb(167,29,93)">mutating</span> <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">addProduct</span>(lhs: <span style="color:rgb(167,29,93)">Self</span>, <span style="color:rgb(121,93,163)">_</span> <span>rhs</span>: <span style="color:rgb(167,29,93)">Self</span>)

  <span style="color:rgb(150,152,150)">/// Remainder of `self` divided by `other`.</span>
  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">remainder</span>(<span style="color:rgb(121,93,163)">dividingBy</span> <span>other</span>: <span style="color:rgb(167,29,93)">Self</span>) <span style="color:rgb(167,29,93)">-&gt;</span> Self

  <span style="color:rgb(150,152,150)">/// Remainder of `self` divided by `other` using truncating division.</span>
  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">truncatingRemainder</span>(<span style="color:rgb(121,93,163)">dividingBy</span> <span>other</span>: <span style="color:rgb(167,29,93)">Self</span>) <span style="color:rgb(167,29,93)">-&gt;</span> Self

  <span style="color:rgb(150,152,150)">/// Square root of `self`.</span>
  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">squareRoot</span>( ) <span style="color:rgb(167,29,93)">-&gt;</span> Self

  <span style="color:rgb(150,152,150)">/// `self + lhs*rhs` computed without intermediate rounding.</span>
  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">addingProduct</span>(lhs: <span style="color:rgb(167,29,93)">Self</span>, <span style="color:rgb(121,93,163)">_</span> <span>rhs</span>: <span style="color:rgb(167,29,93)">Self</span>) <span style="color:rgb(167,29,93)">-&gt;</span> Self

  <span style="color:rgb(150,152,150)">/// The minimum of `x` and `y`.  Implements the IEEE 754 `minNum` operation.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// Returns `x` if `x &lt;= y`, `y` if `y &lt; x`, and whichever of `x` or `y`</span>
  <span style="color:rgb(150,152,150)">/// is a number if the other is NaN.  The result is NaN only if both </span>
  <span style="color:rgb(150,152,150)">/// arguments are NaN.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// This function is an implementation hook to be used by the free function</span>
  <span style="color:rgb(150,152,150)">/// min(Self, Self) -&gt; Self so that we get the IEEE 754 behavior with regard</span>
  <span style="color:rgb(150,152,150)">/// to NaNs.</span>
  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">static</span> <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">minimum</span>(x: <span style="color:rgb(167,29,93)">Self</span>, <span style="color:rgb(121,93,163)">_</span> <span>y</span>: <span style="color:rgb(167,29,93)">Self</span>) <span style="color:rgb(167,29,93)">-&gt;</span> Self

  <span style="color:rgb(150,152,150)">/// The maximum of `x` and `y`.  Implements the IEEE 754 `maxNum` operation.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// Returns `x` if `x &gt;= y`, `y` if `y &gt; x`, and whichever of `x` or `y`</span>
  <span style="color:rgb(150,152,150)">/// is a number if the other is NaN.  The result is NaN only if both</span>
  <span style="color:rgb(150,152,150)">/// arguments are NaN.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// This function is an implementation hook to be used by the free function</span>
  <span style="color:rgb(150,152,150)">/// max(Self, Self) -&gt; Self so that we get the IEEE 754 behavior with regard</span>
  <span style="color:rgb(150,152,150)">/// to NaNs.</span>
  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">static</span> <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">maximum</span>(x: <span style="color:rgb(167,29,93)">Self</span>, <span style="color:rgb(121,93,163)">_</span> <span>y</span>: <span style="color:rgb(167,29,93)">Self</span>) <span style="color:rgb(167,29,93)">-&gt;</span> Self

  <span style="color:rgb(150,152,150)">/// Whichever of `x` or `y` has lesser magnitude.  Implements the IEEE 754</span>
  <span style="color:rgb(150,152,150)">/// `minNumMag` operation.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// Returns `x` if abs(x) &lt;= abs(y), `y` if abs(y) &lt; abs(x), and whichever of</span>
  <span style="color:rgb(150,152,150)">/// `x` or `y` is a number if the other is NaN.  The result is NaN</span>
  <span style="color:rgb(150,152,150)">/// only if both arguments are NaN.</span>
  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">static</span> <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">minimumMagnitude</span>(x: <span style="color:rgb(167,29,93)">Self</span>, <span style="color:rgb(121,93,163)">_</span> <span>y</span>: <span style="color:rgb(167,29,93)">Self</span>) <span style="color:rgb(167,29,93)">-&gt;</span> Self

  <span style="color:rgb(150,152,150)">/// Whichever of `x` or `y` has greater magnitude.  Implements the IEEE 754</span>
  <span style="color:rgb(150,152,150)">/// `maxNumMag` operation.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// Returns `x` if abs(x) &gt;= abs(y), `y` if abs(y) &gt; abs(x), and whichever of</span>
  <span style="color:rgb(150,152,150)">/// `x` or `y` is a number if the other is NaN.  The result is NaN</span>
  <span style="color:rgb(150,152,150)">/// only if both arguments are NaN.</span>
  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">static</span> <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">maximumMagnitude</span>(x: <span style="color:rgb(167,29,93)">Self</span>, <span style="color:rgb(121,93,163)">_</span> <span>y</span>: <span style="color:rgb(167,29,93)">Self</span>) <span style="color:rgb(167,29,93)">-&gt;</span> Self

  <span style="color:rgb(150,152,150)">/// IEEE 754 equality predicate.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// -0 compares equal to +0, and NaN compares not equal to anything,</span>
  <span style="color:rgb(150,152,150)">/// including itself.</span>
  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">isEqual</span>(<span style="color:rgb(121,93,163)">to</span> <span>other</span>: <span style="color:rgb(167,29,93)">Self</span>) <span style="color:rgb(167,29,93)">-&gt;</span> <span style="color:rgb(0,134,179)">Bool</span>

  <span style="color:rgb(150,152,150)">/// IEEE 754 less-than predicate.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// NaN compares not less than anything.  -infinity compares less than</span>
  <span style="color:rgb(150,152,150)">/// all values except for itself and NaN.  Everything except for NaN and</span>
  <span style="color:rgb(150,152,150)">/// +infinity compares less than +infinity.</span>
  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">isLess</span>(<span style="color:rgb(121,93,163)">than</span> <span>other</span>: <span style="color:rgb(167,29,93)">Self</span>) <span style="color:rgb(167,29,93)">-&gt;</span> <span style="color:rgb(0,134,179)">Bool</span>

  <span style="color:rgb(150,152,150)">/// IEEE 754 less-than-or-equal predicate.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// NaN compares not less than or equal to anything, including itself.</span>
  <span style="color:rgb(150,152,150)">/// -infinity compares less than or equal to everything except NaN.</span>
  <span style="color:rgb(150,152,150)">/// Everything except NaN compares less than or equal to +infinity.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// Because of the existence of NaN in FloatingPoint types, trichotomy does</span>
  <span style="color:rgb(150,152,150)">/// not hold, which means that `x &lt; y` and `!(y &lt;= x)` are not equivalent.</span>
  <span style="color:rgb(150,152,150)">/// This is why `isLessThanOrEqual(to:)` is a separate implementation hook</span>
  <span style="color:rgb(150,152,150)">/// in the protocol.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// Note that this predicate does not impose a total order.  The `totalOrder`</span>
  <span style="color:rgb(150,152,150)">/// predicate provides a refinement satisfying that criteria.</span>
  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">isLessThanOrEqual</span>(<span style="color:rgb(121,93,163)">to</span> <span>other</span>: <span style="color:rgb(167,29,93)">Self</span>) <span style="color:rgb(167,29,93)">-&gt;</span> <span style="color:rgb(0,134,179)">Bool</span>

  <span style="color:rgb(150,152,150)">/// IEEE 754 unordered predicate.  True if either `self` or `other` is NaN,</span>
  <span style="color:rgb(150,152,150)">/// and false otherwise.</span>
  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">isUnordered</span>(<span style="color:rgb(121,93,163)">with</span> <span>other</span>: <span style="color:rgb(167,29,93)">Self</span>) <span style="color:rgb(167,29,93)">-&gt;</span> <span style="color:rgb(0,134,179)">Bool</span>

  <span style="color:rgb(150,152,150)">/// True if and only if `self` is normal.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// A normal number uses the full precision available in the format.  Zero</span>
  <span style="color:rgb(150,152,150)">/// is not a normal number.</span>
  <span style="color:rgb(167,29,93)">var</span> isNormal: <span style="color:rgb(0,134,179)">Bool</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// True if and only if `self` is finite.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// If `x.isFinite` is `true`, then one of `x.isZero`, `x.isSubnormal`, or</span>
  <span style="color:rgb(150,152,150)">/// `x.isNormal` is also `true`, and `x.isInfinite` and `x.isNan` are</span>
  <span style="color:rgb(150,152,150)">/// `false`.</span>
  <span style="color:rgb(167,29,93)">var</span> isFinite: <span style="color:rgb(0,134,179)">Bool</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// True iff `self` is zero.  Equivalent to `self == 0`.</span>
  <span style="color:rgb(167,29,93)">var</span> isZero: <span style="color:rgb(0,134,179)">Bool</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// True if and only if `self` is subnormal.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// A subnormal number does not use the full precision available to normal</span>
  <span style="color:rgb(150,152,150)">/// numbers of the same format.  Zero is not a subnormal number.</span>
  <span style="color:rgb(167,29,93)">var</span> isSubnormal: <span style="color:rgb(0,134,179)">Bool</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// True if and only if `self` is infinite.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// Note that `isFinite` and `isInfinite` do not form a dichotomy, because</span>
  <span style="color:rgb(150,152,150)">/// they are not total.  If `x` is `NaN`, then both properties are `false`.</span>
  <span style="color:rgb(167,29,93)">var</span> isInfinite: <span style="color:rgb(0,134,179)">Bool</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// True if and only if `self` is NaN (&quot;not a number&quot;).</span>
  <span style="color:rgb(167,29,93)">var</span> isNan: <span style="color:rgb(0,134,179)">Bool</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// True if and only if `self` is a signaling NaN.</span>
  <span style="color:rgb(167,29,93)">var</span> isSignalingNan: <span style="color:rgb(0,134,179)">Bool</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// The IEEE 754 &quot;class&quot; of this type.</span>
  <span style="color:rgb(167,29,93)">var</span> floatingPointClass: <span style="color:rgb(0,134,179)">FloatingPointClassification</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// True if and only if `self` is canonical.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// Every floating-point value of type Float or Double is canonical, but</span>
  <span style="color:rgb(150,152,150)">/// non-canonical values of type Float80 exist, and non-canonical values</span>
  <span style="color:rgb(150,152,150)">/// may exist for other types that conform to FloatingPoint.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// The non-canonical Float80 values are known as &quot;pseudo-denormal&quot;,</span>
  <span style="color:rgb(150,152,150)">/// &quot;unnormal&quot;, &quot;pseudo-infinity&quot;, and &quot;pseudo-NaN&quot;.</span>
  <span style="color:rgb(150,152,150)">/// (<a href="https://en.wikipedia.org/wiki/Extended_precision#x86_Extended_Precision_Format" target="_blank">https://en.wikipedia.org/wiki/Extended_precision#x86_Extended_Precision_Format</a>)</span>
  <span style="color:rgb(167,29,93)">var</span> isCanonical: <span style="color:rgb(0,134,179)">Bool</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// True if and only if `self` preceeds `other` in the IEEE 754 total order</span>
  <span style="color:rgb(150,152,150)">/// relation.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// This relation is a refinement of `&lt;=` that provides a total order on all</span>
  <span style="color:rgb(150,152,150)">/// values of type `Self`, including non-canonical encodings, signed zeros,</span>
  <span style="color:rgb(150,152,150)">/// and NaNs.  Because it is used much less frequently than the usual</span>
  <span style="color:rgb(150,152,150)">/// comparisons, there is no operator form of this relation.</span>
  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">totalOrder</span>(<span style="color:rgb(121,93,163)">with</span> <span>other</span>: <span style="color:rgb(167,29,93)">Self</span>) <span style="color:rgb(167,29,93)">-&gt;</span> <span style="color:rgb(0,134,179)">Bool</span>

  <span style="color:rgb(150,152,150)">/// True if and only if `abs(self)` preceeds `abs(other)` in the IEEE 754</span>
  <span style="color:rgb(150,152,150)">/// total order relation.</span>
  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">totalOrderMagnitude</span>(<span style="color:rgb(121,93,163)">with</span> <span>other</span>: <span style="color:rgb(167,29,93)">Self</span>) <span style="color:rgb(167,29,93)">-&gt;</span> <span style="color:rgb(0,134,179)">Bool</span>

  <span style="color:rgb(150,152,150)">/// The closest representable value to the argument.</span>
  <span style="color:rgb(167,29,93)">init</span><span style="color:rgb(167,29,93)">&lt;</span>Source: Integer<span style="color:rgb(167,29,93)">&gt;</span>(_ value: Source)

  <span style="color:rgb(150,152,150)">/// Fails if the argument cannot be exactly represented.</span>
  <span style="color:rgb(167,29,93)">init</span>?<span style="color:rgb(167,29,93)">&lt;</span>Source: Integer<span style="color:rgb(167,29,93)">&gt;</span>(exactly value: Source)
}</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">The <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">BinaryFloatingPoint</code> protocol provides a number of additional APIs that only make sense for types with fixed radix 2:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,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"><span style="color:rgb(150,152,150)">/// A radix-2 (binary) floating-point type that follows the IEEE 754 encoding</span>
<span style="color:rgb(150,152,150)">/// conventions.</span>
<span style="color:rgb(167,29,93)">public</span> <span style="color:rgb(167,29,93)">protocol</span> BinaryFloatingPoint: FloatingPoint {

  <span style="color:rgb(150,152,150)">/// The number of bits used to represent the exponent.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// Following IEEE 754 encoding convention, the exponent bias is:</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">///   bias = 2**(exponentBitCount-1) - 1</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// The least normal exponent is `1-bias` and the largest finite exponent</span>
  <span style="color:rgb(150,152,150)">/// is `bias`.  The all-zeros exponent is reserved for subnormals and zeros,</span>
  <span style="color:rgb(150,152,150)">/// and the all-ones exponent is reserved for infinities and NaNs.</span>
  <span style="color:rgb(167,29,93)">static</span> <span style="color:rgb(167,29,93)">var</span> exponentBitCount: <span style="color:rgb(0,134,179)">Int</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// For fixed-width floating-point types, this is the number of fractional</span>
  <span style="color:rgb(150,152,150)">/// significand bits.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// For extensible floating-point types, `significandBitCount` should be</span>
  <span style="color:rgb(150,152,150)">/// the maximum allowed significand width (without counting any leading</span>
  <span style="color:rgb(150,152,150)">/// integral bit of the significand).  If there is no upper limit, then</span>
  <span style="color:rgb(150,152,150)">/// `significandBitCount` should be `Int.max`.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// Note that `Float80.significandBitCount` is 63, even though 64 bits</span>
  <span style="color:rgb(150,152,150)">/// are used to store the significand in the memory representation of a</span>
  <span style="color:rgb(150,152,150)">/// `Float80` (unlike other floating-point types, `Float80` explicitly</span>
  <span style="color:rgb(150,152,150)">/// stores the leading integral significand bit, but the</span>
  <span style="color:rgb(150,152,150)">/// `BinaryFloatingPoint` APIs provide an abstraction so that users don&#39;t</span>
  <span style="color:rgb(150,152,150)">/// need to be aware of this detail).</span>
  <span style="color:rgb(167,29,93)">static</span> <span style="color:rgb(167,29,93)">var</span> significandBitCount: <span style="color:rgb(0,134,179)">Int</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// The raw encoding of the exponent field of the floating-point value.</span>
  <span style="color:rgb(167,29,93)">var</span> exponentBitPattern: <span style="color:rgb(0,134,179)">UInt</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// The raw encoding of the significand field of the floating-point value.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// `significandBitPattern` does *not* include the leading integral bit of</span>
  <span style="color:rgb(150,152,150)">/// the significand, even for types like `Float80` that store it explicitly.</span>
  <span style="color:rgb(167,29,93)">var</span> significandBitPattern: RawSignificand { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// Combines `signBit`, `exponent` and `significand` bit patterns to produce</span>
  <span style="color:rgb(150,152,150)">/// a floating-point value.</span>
  <span style="color:rgb(167,29,93)">init</span>(signBit: <span style="color:rgb(0,134,179)">Bool</span>,
       exponentBitPattern: <span style="color:rgb(0,134,179)">UInt</span>,
       significandBitPattern: RawSignificand)

  <span style="color:rgb(150,152,150)">/// The least-magnitude member of the binade of `self`.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// If `x` is `+/-significand * 2**exponent`, then `x.binade` is</span>
  <span style="color:rgb(150,152,150)">/// `+/- 2**exponent`; i.e. the floating point number with the same sign</span>
  <span style="color:rgb(150,152,150)">/// and exponent, but with a significand of 1.0.</span>
  <span style="color:rgb(167,29,93)">var</span> binade: <span style="color:rgb(167,29,93)">Self</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(150,152,150)">/// The number of bits required to represent significand.</span>
  <span style="color:rgb(150,152,150)">///</span>
  <span style="color:rgb(150,152,150)">/// If `self` is not a finite non-zero number, `significandWidth` is</span>
  <span style="color:rgb(150,152,150)">/// `-1`.  Otherwise, it is the number of bits required to represent the</span>
  <span style="color:rgb(150,152,150)">/// significand exactly (less `1` because common formats represent one bit</span>
  <span style="color:rgb(150,152,150)">/// implicitly).</span>
  <span style="color:rgb(167,29,93)">var</span> significandWidth: <span style="color:rgb(0,134,179)">Int</span> { <span style="color:rgb(167,29,93)">get</span> }

  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">isEqual</span>&lt;Other: BinaryFloatingPoint&gt;(<span style="color:rgb(121,93,163)">to</span> <span>other</span>: Other) <span style="color:rgb(167,29,93)">-&gt;</span> <span style="color:rgb(0,134,179)">Bool</span>

  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">isLess</span>&lt;Other: BinaryFloatingPoint&gt;(<span style="color:rgb(121,93,163)">than</span> <span>other</span>: Other) <span style="color:rgb(167,29,93)">-&gt;</span> <span style="color:rgb(0,134,179)">Bool</span>

  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">isLessThanOrEqual</span>&lt;Other: BinaryFloatingPoint&gt;(<span style="color:rgb(121,93,163)">to</span> <span>other</span>: Other) <span style="color:rgb(167,29,93)">-&gt;</span> <span style="color:rgb(0,134,179)">Bool</span>

  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">isUnordered</span>&lt;Other: BinaryFloatingPoint&gt;(<span style="color:rgb(121,93,163)">with</span> <span>other</span>: Other) <span style="color:rgb(167,29,93)">-&gt;</span> <span style="color:rgb(0,134,179)">Bool</span>

  <span style="color:rgb(167,29,93)">@warn_unused_result</span>
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">totalOrder</span>&lt;Other: BinaryFloatingPoint&gt;(<span style="color:rgb(121,93,163)">with</span> <span>other</span>: Other) <span style="color:rgb(167,29,93)">-&gt;</span> <span style="color:rgb(0,134,179)">Bool</span>

  <span style="color:rgb(150,152,150)">/// `value` rounded to the closest representable value.</span>
  <span style="color:rgb(167,29,93)">init</span><span style="color:rgb(167,29,93)">&lt;</span>Source: BinaryFloatingPoint<span style="color:rgb(167,29,93)">&gt;</span>(_ value: Source)

  <span style="color:rgb(150,152,150)">/// Fails if `value` cannot be represented exactly as `Self`.</span>
  <span style="color:rgb(167,29,93)">init</span>?<span style="color:rgb(167,29,93)">&lt;</span>Source: BinaryFloatingPoint<span style="color:rgb(167,29,93)">&gt;</span>(exactly value: Source)
}</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Float</code>, <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Double</code>, <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Float80</code> and <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">CGFloat</code> will conform to all of these protocols.</p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">A small portion of the implementation of these APIs is dependent on new Integer protocols that will be proposed separately. Everything else is implemented in draft form on the branch floating-point-revision of <a href="https://github.com/stephentyrone/swift" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">my fork</a>.</p><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://github.com/stephentyrone/swift-evolution/blob/master/NNNN-floating-point-protocols.md#impact-on-existing-code" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Impact on existing code</h2><ol style="padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><li><p style="margin-top:16px;margin-bottom:16px">The <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">%</code> operator is no longer available for FloatingPoint types. We don&#39;t believe that it was widely used correctly, and the operation is still available via the <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">formTruncatingRemainder</code> method for people who need it.</p></li><li><p style="margin-top:16px;margin-bottom:16px">To follow the naming guidelines, <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">NaN</code> and <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">isNaN</code> are replaced with <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">nan</code> and <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">isNan</code>.</p></li><li><p style="margin-top:16px;margin-bottom:16px">The redundant property <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">quietNaN</code> is removed.</p></li><li><p style="margin-top:16px;margin-bottom:16px"><code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">isSignaling</code> is renamed <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">isSignalingNan</code>.</p></li></ol><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://github.com/stephentyrone/swift-evolution/blob/master/NNNN-floating-point-protocols.md#alternatives-considered" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><u></u><u></u><u></u><u></u></a>Alternatives considered</h2><div style="margin-top:0px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255);margin-bottom:0px!important">N/A.</div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>