<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br></div><div><br>On 31 Mar 2017, at 04:21, David Sweeris <<a href="mailto:davesweeris@mac.com">davesweeris@mac.com</a>> wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><br></div><div><div><br><br>Sent from my iPhone</div>On Mar 30, 2017, at 14:56, David Hart via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8">Hello swift-evolution,<div class=""><br class=""></div><div class="">I’m working on a proposal for arbitrary precision integer and float literal protocols to complement ExpressibleByIntegerLiteral and ExpressibleByFloatLiteral. I’m looking for feedback and help in verifying the logic - I have doubts about endianness.</div><div class=""><br class=""></div><div class="">Fire away!</div><div class=""><br class=""></div><div class=""><a href="https://github.com/hartbit/swift-evolution/blob/arbitrary-precision-integer-float-protocol/proposals/XXXX-arbitrary-precision-integer-float-literal-protocols.md" class="">https://github.com/hartbit/swift-evolution/blob/arbitrary-precision-integer-float-protocol/proposals/XXXX-arbitrary-precision-integer-float-literal-protocols.md</a></div><div class=""><br class=""></div><div class=""><h1 style="box-sizing: border-box; margin-right: 0px; margin-bottom: 16px; margin-left: 0px; line-height: 1.25; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(234, 236, 239); color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255); margin-top: 0px !important;" class="">Arbitrary precision integer and float literal procotols</h1><ul style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, 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="">Proposal: <a href="https://github.com/hartbit/swift-evolution/blob/arbitrary-precision-integer-float-protocol/proposals/XXXX-arbitrary-precision-integer-float-literal-protocols.md" style="box-sizing: border-box; background-color: transparent; -webkit-text-decoration-skip: objects; color: rgb(3, 102, 214); text-decoration: none;" class="">SE-XXXX</a></li><li style="box-sizing: border-box; margin-top: 0.25em;" class="">Authors: <a href="https://github.com/hartbit" style="box-sizing: border-box; background-color: transparent; -webkit-text-decoration-skip: objects; color: rgb(3, 102, 214); text-decoration: none;" class="">David Hart</a></li><li style="box-sizing: border-box; margin-top: 0.25em;" class="">Review Manager: <em style="box-sizing: border-box;" class="">TBD</em></li><li style="box-sizing: border-box; margin-top: 0.25em;" class="">Status: <em style="box-sizing: border-box;" class="">TBD</em></li></ul><h2 style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; line-height: 1.25; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(234, 236, 239); color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);" class=""><a id="user-content-introduction" class="anchor" href="https://github.com/hartbit/swift-evolution/tree/arbitrary-precision-integer-float-protocol#introduction" aria-hidden="true" style="box-sizing: border-box; background-color: transparent; -webkit-text-decoration-skip: objects; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; margin-left: -20px; line-height: 1;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Introduction</h2><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class="">We propose a pair of protocols extending <code style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">ExpressibleByIntegerLiteral</code> and <code style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">ExpressibleByFloatLiteral</code> to allow initializing conforming types with arbitrary precision integer and floating-point literals.</p><h2 style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; line-height: 1.25; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(234, 236, 239); color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);" class=""><a id="user-content-motivation" class="anchor" href="https://github.com/hartbit/swift-evolution/tree/arbitrary-precision-integer-float-protocol#motivation" aria-hidden="true" style="box-sizing: border-box; background-color: transparent; -webkit-text-decoration-skip: objects; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; margin-left: -20px; line-height: 1;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Motivation</h2><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class="">The current protocols <code style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">ExpressibleByIntegerLiteral</code> and <code style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">ExpressibleByFloatLiteral</code> are simple and work well but don't support arbitrary precision literal values. Replacing those protocols is a non-goal as they provide a simple interface for work well for most cases. Therefore, to support initializing big integer and big float types with literal values, we need new protocols.</p><h2 style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; line-height: 1.25; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(234, 236, 239); color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);" class=""><a id="user-content-proposed-solution" class="anchor" href="https://github.com/hartbit/swift-evolution/tree/arbitrary-precision-integer-float-protocol#proposed-solution" aria-hidden="true" style="box-sizing: border-box; background-color: transparent; -webkit-text-decoration-skip: objects; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; margin-left: -20px; line-height: 1;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Proposed solution</h2><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class="">We propose:</p><ul style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, 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="">renaming <code style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">FloatingPointSign</code> into <code style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">Sign</code>,</li><li style="box-sizing: border-box; margin-top: 0.25em;" class="">introducing a <code style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">ExpressibleByArbitraryPrecisionIntegerLiteral</code> protocol that extends <code style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">ExpressibleByIntegerLiteral</code> and provides a new arbitrary precision initializer,</li><li style="box-sizing: border-box; margin-top: 0.25em;" class="">introducing a <code style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">ExpressibleByArbitraryPrecisionFloatLiteral</code> protocol that extends <code style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" class="">ExpressibleByFloatLiteral</code> and provides a new arbitrary precision initializer.</li></ul><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class="">Here is the corresponding code:</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, 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; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;" class=""><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> The sign of a number.</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><span class="pl-k" style="color: rgb(167, 29, 93); box-sizing: border-box;">public</span><font color="#24292e" class=""> </font><span class="pl-k" style="color: rgb(167, 29, 93); box-sizing: border-box;">enum</span><font color="#24292e" class=""> </font><span class="pl-en" style="color: rgb(121, 93, 163); box-sizing: border-box;">Sign</span><font color="#24292e" class=""> : </font><span class="pl-e" style="color: rgb(121, 93, 163); box-sizing: border-box;"><span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span> </span><font color="#24292e" class="">{
</font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> The sign for a positive value.</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-k" style="color: rgb(167, 29, 93); box-sizing: border-box;">case</span><font color="#24292e" class=""> </font><span class="pl-c1" style="color: rgb(0, 134, 179); box-sizing: border-box;">plus</span><font color="#24292e" class="">
</font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> The sign for a negative value.</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-k" style="color: rgb(167, 29, 93); box-sizing: border-box;">case</span><font color="#24292e" class=""> </font><span class="pl-c1" style="color: rgb(0, 134, 179); box-sizing: border-box;">minus</span><font color="#24292e" class="">
}
</font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> A type that can be initialized with an arbitrary precision integer literal.</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><span class="pl-k" style="color: rgb(167, 29, 93); box-sizing: border-box;">public</span><font color="#24292e" class=""> </font><span class="pl-k" style="color: rgb(167, 29, 93); box-sizing: border-box;">protocol</span><font color="#24292e" class=""> </font><span class="pl-en" style="color: rgb(121, 93, 163); box-sizing: border-box;">ExpressibleByArbitraryPrecisionIntegerLiteral</span><font color="#24292e" class="">:
</font><span class="pl-e" style="color: rgb(121, 93, 163); box-sizing: border-box;"><span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">ExpressibleByIntegerLiteral</span> </span><font color="#24292e" class="">{
</font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> Creates an instance initialized with the sign and memory value of the</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> arbitrary precision integer literal.</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;">///</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> Do not call this initializer directly. Instead, initialize a variable or</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> constant using an arbitrary precision integer literal. For example:</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;">///</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> let x = 123_456_789_123_456_789_123_456_789</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;">///</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> In this example, the assignment to the `x` constant calls this integer</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> literal initializer behind the scenes with `sign` as `.plus` and</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;"><font color="#24292e" class=""> </font><font color="#969896" class="">///</font></span><font color="#969896" class=""> `buffer` as the memory [0x0000000000661EFD, 0xF2E3B19F7C045F15].</font></span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;">///</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> - Parameters:</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> sign: The sign of the integer value.</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> buffer: The memory value of the integer.</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-k" style="color: rgb(167, 29, 93); box-sizing: border-box;">init</span><font color="#24292e" class="">(</font><span class="pl-smi" style="color: rgb(51, 51, 51); box-sizing: border-box;"><span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">sign</span></span><font color="#24292e" class="">: Sign, </font><span class="pl-smi" style="color: rgb(51, 51, 51); box-sizing: border-box;"><span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">buffer</span></span><font color="#24292e" class="">: </font><span class="pl-c1" style="color: rgb(0, 134, 179); box-sizing: border-box;">UnsafeBufferPointer</span><font color="#24292e" class=""><</font><span class="pl-c1" style="color: rgb(0, 134, 179); box-sizing: border-box;">UInt64</span><font color="#24292e" class="">>)
}
</font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> A type that can be initialized with an arbitrary precision float literal.</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><span class="pl-k" style="color: rgb(167, 29, 93); box-sizing: border-box;">public</span><font color="#24292e" class=""> </font><span class="pl-k" style="color: rgb(167, 29, 93); box-sizing: border-box;">protocol</span><font color="#24292e" class=""> </font><span class="pl-en" style="color: rgb(121, 93, 163); box-sizing: border-box;">ExpressibleByArbitraryPrecisionFloatLiteral</span><font color="#24292e" class="">:
</font><span class="pl-e" style="color: rgb(121, 93, 163); box-sizing: border-box;"><span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">ExpressibleByFloatLiteral</span> </span><font color="#24292e" class="">{
</font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> Creates an instance initialized with the sign, exponent and</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> significand of the arbitrary precision float literal.</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;">///</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> Do not call this initializer directly. Instead, initialize a variable or</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> constant using an arbitrary precision integer literal. For example:</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;">///</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> let x = 123_456_789_123_456.789_123_456_789</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;">///</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> In this example, the assignment to the `x` constant calls this float</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> literal initializer behind the scenes with `sign` as `.plus`, `exponent`</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> as the memory [0x0000000000661EFD, 0xF2E3B19F7C045F15] and `significand`</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> with value [0x000000000000000C].</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;">///</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> - Parameters:</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> sign: The sign of the integer value.</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> exponent: The memory value of the exponent.</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-c" style="color: rgb(150, 152, 150); box-sizing: border-box;"><span class="pl-c" style="box-sizing: border-box;">///</span> significand: The memory value of the significand.</span><font color="#24292e" class="">
</font><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><font color="#24292e" class=""> </font><span class="pl-k" style="color: rgb(167, 29, 93); box-sizing: border-box;">init</span><font color="#24292e" class="">(
</font><span class="pl-smi" style="color: rgb(51, 51, 51); box-sizing: border-box;"><span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">sign</span></span><font color="#24292e" class="">: Sign,
</font><span class="pl-smi" style="color: rgb(51, 51, 51); box-sizing: border-box;"><span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">exponent</span></span><font color="#24292e" class="">: </font><span class="pl-c1" style="color: rgb(0, 134, 179); box-sizing: border-box;">UnsafeBufferPointer</span><font color="#24292e" class=""><</font><span class="pl-c1" style="color: rgb(0, 134, 179); box-sizing: border-box;">UInt64</span><font color="#24292e" class="">>,
</font><span class="pl-smi" style="color: rgb(51, 51, 51); box-sizing: border-box;"><span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">significand</span></span><font color="#24292e" class="">: </font><span class="pl-c1" style="color: rgb(0, 134, 179); box-sizing: border-box;">UnsafeBufferPointer</span><font color="#24292e" class=""><</font><span class="pl-c1" style="color: rgb(0, 134, 179); box-sizing: border-box;">UInt64</span><font color="#24292e" class="">>)
}</font></pre></div><div class=""><br class=""></div></div><div class=""><br class=""></div><div class=""><br class=""></div></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote><br><div><span style="background-color: rgba(255, 255, 255, 0);">IIRC, some branches of math don't consider 0 to be positive or negative, so </span>I might add a `zero` case in `Sign`.</div></div></blockquote><div><br></div><div>That will never happen: the literal value 0 on a type conforming to one of those protocols will call the super-protocol's initializer because it is representable with all built-in types.</div><br><blockquote type="cite"><div><div>Also, I'm not sure new protocols are actually necessary. I think I remember hearing somewhere that LLVM supports integer literals up to something like 400 bits? If so, we'd merely need a type that exposes those bytes to set the relevant types `IntegerLiteralType` associated type.</div></div></blockquote><div><br></div><div>I am clueless in this regard so please let me know if you find more information.</div><br><blockquote type="cite"><div><div>- Dave Sweeris </div></div></blockquote></body></html>