<div dir="ltr">On Tue, Jan 16, 2018 at 5:39 PM, Rick Mann <span dir="ltr">&lt;<a href="mailto:rmann@latencyzero.com" target="_blank">rmann@latencyzero.com</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
&gt; On Jan 16, 2018, at 15:32 , Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt; On Jan 16, 2018, at 14:30 , Nevin Brackett-Rozinsky via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; That only works for numbers which don’t overflow the integer literals though. If we want a really large or small value then we have to split it in pieces:<br>
<span class="">&gt;&gt;<br>
&gt;&gt; func moles &lt;T: FloatingPoint&gt; (particles: T) -&gt; T {<br>
&gt;&gt;     let avogadroNumber: T = 6_022_140_857 * 100_000_000_000_000<br>
&gt;&gt;     return particles / avogadroNumber<br>
&gt;&gt; }<br>
&gt;&gt;<br>
&gt;&gt; It would be much nicer to write “let avogadroNumber: T = 6.022140857e23”.<br>
&gt;&gt;<br>
&gt;<br>
&gt; You could write:<br>
&gt;<br>
&gt; func moles&lt;T : FloatingPoint &amp; LosslessStringConvertible&gt;(<wbr>particles: T) -&gt; T {<br>
&gt;   let N_A = T(&quot;6.02214085774e+23&quot;)!<br>
&gt;   return particles / N_A<br>
&gt; }<br>
<br>
</span>You&#39;re not seriously proposing this alternative, are you? I&#39;m with Nevin on this: “let avogadroNumber: T = 6.022140857e23”.<br></blockquote><div><br></div><div>I&#39;m quite serious. You&#39;ll recall above that I mentioned one possible design for an alternative protocol is one that initializes via a string representation of the literal. The alternative given above uses the same functionality in a spelling that&#39;s already available. All binary floating-point types already do support converting from a string, and any future IEEE-compliant decimal floating-point type will necessarily have the logic that supports it. This alternative allows Nevin to use scientific notation as he desires, and it allows him to write generic algorithms constrained to FloatingPoint (which, still, I don&#39;t understand why; that protocol makes very few useful guarantees and there isn&#39;t much you can do with it in practice--we may in fact be better off getting rid of it altogether; in the meantime, one simple improvement would be to make FloatingPoint refine LosslessStringConvertible, as some integer protocols now do).</div><div><br></div></div></div></div>