<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Mainly semantics.<div class=""><br class=""></div><div class="">We could technically use Int instead of having a Bool type (just using 1 and 0). &nbsp;We don’t do that since Int and Bool have intrinsically different meanings in code. &nbsp;</div><div class=""><br class=""></div><div class="">What I am saying is that parameters that take the range 0 to 1 typically have a fundamentally different meaning (or at least a different way of thinking about them) than Doubles. &nbsp;It would be nice to be able to see that distinction when using APIs.</div><div class=""><br class=""></div><div class="">With both this and the Angle type, I am pointing out areas where, due to historical reasons in C, we have conflated a bunch of types which have different behavior, and then just expect programmers to be conscientious enough to use them correctly in each case. &nbsp;These types/numbers all have a different forms of dimensionality.</div><div class=""><br class=""></div><div class="">I’d like to discuss that before we lock everything down.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Jon</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 13, 2018, at 9:18 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">As Erica mentioned about Angle, this seems to be a perfect fit for an appropriately focused third-party library, but I'm not sure I appreciate why this should be part of the standard library. In large part, you seem to have reinvented a decimal type, which is already available in the form of Foundation.Decimal on all supported platforms.</div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sat, Jan 13, 2018 at 9:07 PM, Jonathan Hull via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Here is the code I use for percentage myself. (I incorrectly said I use a UInt64… I use a UInt32):<div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,128,0);background-color:rgb(255,255,255)" class="">///Represents a percentage with the precision of millionths of 1 (i.e. 4 decimal places: XX.XXXX%). The value is always positive (or zero), but may be greater than 100%</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="color:#0433ff" class="">struct</span> Percentage {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">fileprivate(set)</span> <span style="color:#0433ff" class="">var</span> millionths:<span style="color:#3495af" class="">UInt32</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">fileprivate</span> <span style="color:#0433ff" class="">init</span>(storage:<span style="color:#3495af" class="">UInt32</span>){</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#3495af" class="">millionths</span> = storage</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">static</span> <span style="color:#0433ff" class="">var</span> quarter = <span style="color:#3495af" class="">Percentage</span>(storage: 250_000)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">static</span> <span style="color:#0433ff" class="">var</span> half&nbsp; &nbsp; = <span style="color:#3495af" class="">Percentage</span>(storage: 500_000)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">static</span> <span style="color:#0433ff" class="">var</span> threeQuarters = <span style="color:#3495af" class="">Percentage</span>(storage: 750_000)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">static</span> <span style="color:#0433ff" class="">var</span> full&nbsp; &nbsp; = <span style="color:#3495af" class="">Percentage</span>(storage: 1_000_000)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">init</span>(millionths:<span style="color:#3495af" class="">Int</span>) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span> = <span style="color:#3495af" class="">UInt32</span>(millionths)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">init</span>(<span style="color:#0433ff" class="">_</span> double:<span style="color:#3495af" class="">Double</span>, range:<span style="color:#3495af" class="">ClosedRange</span>&lt;<span style="color:#3495af" class="">Double</span>&gt; = 0...1) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">if</span> range == 0...1 {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span> = <span style="color:#3495af" class="">UInt32</span>(<span style="color:#3495af" class="">max</span>(double * 1_000_000, 0))</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; }<span style="color:#0433ff" class="">else</span> <span style="color:#0433ff" class="">if</span> range == 0...100{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span> = <span style="color:#3495af" class="">UInt32</span>(<span style="color:#3495af" class="">max</span>(double * 10_000, 0))</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; }<span style="color:#0433ff" class="">else</span>{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span> = <span style="color:#3495af" class="">UInt32</span>(<span style="color:#3495af" class="">max</span>((double - range.<span style="color:#3495af" class="">lowerBound</span>)/(range.<span style="color:#3495af" class="">upper<wbr class="">Bound</span> - range.<span style="color:#3495af" class="">lowerBound</span>),0))</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">init</span>(<span style="color:#0433ff" class="">_</span> num:<span style="color:#3495af" class="">Num</span>, range:<span style="color:#3495af" class="">ClosedRange</span>&lt;<span style="color:#3495af" class="">Num</span>&gt; = 0...1) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">if</span> range == 0...1 {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span> = <span style="color:#3495af" class="">UInt32</span>(<span style="color:#3495af" class="">max</span>(num * 1_000_000, 0).<span style="color:#3495af" class="">integerValue</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; }<span style="color:#0433ff" class="">else</span> <span style="color:#0433ff" class="">if</span> range == 0...100{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span> = <span style="color:#3495af" class="">UInt32</span>(<span style="color:#3495af" class="">max</span>(num * 10_000, 0).<span style="color:#3495af" class="">integerValue</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; }<span style="color:#0433ff" class="">else</span>{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175);background-color:rgb(255,255,255)" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#0433ff" class="">self</span><span style="" class="">.</span>millionths<span style="" class=""> = </span>UInt32<span style="" class="">(</span>max<span style="" class="">((num - range.</span>lowerBound<span style="" class="">)/(range.</span>upper<wbr class="">Bound<span style="" class=""> - range.</span>lowerBound<span style="" class="">),0).</span>integerVa<wbr class="">lue<span style="" class="">)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">init</span>(<span style="color:#0433ff" class="">_</span> decimal:<span style="color:#3495af" class="">Decimal</span>, range:<span style="color:#3495af" class="">ClosedRange</span>&lt;<span style="color:#3495af" class="">Decimal</span>&gt; = 0...1) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">if</span> range == 0...1 {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span> = <span style="color:#3495af" class="">NSDecimalNumber</span>(decimal: <span style="color:#3495af" class="">max</span>(decimal * 1_000_000, 0)).<span style="color:#3495af" class="">uint32Value</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; }<span style="color:#0433ff" class="">else</span> <span style="color:#0433ff" class="">if</span> range == 0...100{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span> = <span style="color:#3495af" class="">NSDecimalNumber</span>(decimal: <span style="color:#3495af" class="">max</span>(decimal * 10_000, 0)).<span style="color:#3495af" class="">uint32Value</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; }<span style="color:#0433ff" class="">else</span>{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">let</span> shifted = <span style="color:#3495af" class="">max</span>((decimal - range.<span style="color:#3495af" class="">lowerBound</span>)/(range.<span style="color:#3495af" class="">upper<wbr class="">Bound</span> - range.<span style="color:#3495af" class="">lowerBound</span>),0)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175);background-color:rgb(255,255,255)" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#0433ff" class="">self</span><span style="" class="">.</span>millionths<span style="" class=""> = </span>NSDecimalNumber<span style="" class="">(decimal: shifted).</span>uint32Value</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">init</span>(hundredths:<span style="color:#3495af" class="">Int</span>) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span> = <span style="color:#3495af" class="">UInt32</span>(<span style="color:#3495af" class="">max</span>(hundredths * 10_000, 0))</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255);min-height:14px" class=""><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">init</span>(thousandths:<span style="color:#3495af" class="">Int</span>) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span> = <span style="color:#3495af" class="">UInt32</span>(<span style="color:#3495af" class="">max</span>(thousandths * 1_000, 0))</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">var</span> isFull:<span style="color:#3495af" class="">Bool</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> <span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span> &gt;= 1_000_000</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">var</span> doubleValue:<span style="color:#3495af" class="">Double</span>{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> <span style="color:#3495af" class="">Double</span>(<span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span>)/1_000_<wbr class="">000</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">var</span> cgfloatValue:<span style="color:#3495af" class="">CGFloat</span>{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> <span style="color:#3495af" class="">CGFloat</span>(<span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span>)/1_<wbr class="">000_000</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">var</span> decimalValue:<span style="color:#3495af" class="">Decimal</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> <span style="color:#3495af" class="">Decimal</span>(<span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span>)/1_<wbr class="">000_000</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">var</span> numValue:<span style="color:#3495af" class="">Num</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> <span style="color:#3495af" class="">Num</span>(numerator: <span style="color:#3495af" class="">Int32</span>(<span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span>), denominator: 1_000_000)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,143,0);background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">var</span> hundredths:<span style="color:#3495af" class="">Int</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> <span style="color:#3495af" class="">Int</span>(<span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span>/10_000)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">var</span> thousandths:<span style="color:#3495af" class="">Int</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> <span style="color:#3495af" class="">Int</span>(<span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span>/1_000)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">var</span> tenThousandths:<span style="color:#3495af" class="">Int</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> <span style="color:#3495af" class="">Int</span>(<span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span>/100)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">func</span> map(to range:<span style="color:#3495af" class="">ClosedRange</span>&lt;<span style="color:#3495af" class="">Num</span>&gt;) -&gt; <span style="color:#3495af" class="">Num</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> <span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">numValue</span> * (range.<span style="color:#3495af" class="">upperBound</span> - range.<span style="color:#3495af" class="">lowerBound</span>) + range.<span style="color:#3495af" class="">lowerBound</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">mutating</span> <span style="color:#0433ff" class="">func</span> clip() {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">if</span> <span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span> &gt; 1_000_000 {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span> = 1_000_000</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">func</span> clipped()-&gt;<span style="color:#3495af" class="">Percentage</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">if</span> <span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span> &gt; 1_000_000 {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> <span style="color:#3495af" class="">Percentage</span>.<span style="color:#3495af" class="">full</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(4,51,255);background-color:rgb(255,255,255)" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>return<span style="" class=""> </span>self</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">}</div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255);min-height:14px" class=""><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175);background-color:rgb(255,255,255)" class=""><span style="color:#0433ff" class="">extension</span><span style="" class=""> </span>Percentage<span style="" class="">:</span>CustomStringConvert<wbr class="">ible<span style="" class=""> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">var</span> description: <span style="color:#3495af" class="">String</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">let</span> num = <span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">numValue</span> * 100</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">if</span> num.<span style="color:#3495af" class="">isInteger</span>{</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> <span style="color:#b4261a" class="">"</span>\<span style="color:#b4261a" class="">(</span>num<span style="color:#b4261a" class="">)%"</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> <span style="color:#b4261a" class="">"</span>\<span style="color:#b4261a" class="">(</span>num.<span style="color:#3495af" class="">decimalValue</span><span style="color:#b4261a" class="">)%"</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">}</div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255);min-height:14px" class=""><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175);background-color:rgb(255,255,255)" class=""><span style="color:#0433ff" class="">extension</span><span style="" class=""> </span>Percentage<span style="" class="">:</span>ExpressibleByIntege<wbr class="">rLiteral<span style="" class=""> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">init</span>(integerLiteral value: <span style="color:#3495af" class="">IntegerLiteralType</span>) {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">self</span>.<span style="color:#3495af" class="">millionths</span> = <span style="color:#3495af" class="">UInt32</span>(<span style="color:#3495af" class="">max</span>(value * 10_000, 0))</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">}</div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255);min-height:14px" class=""><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175);background-color:rgb(255,255,255)" class=""><span style="color:#0433ff" class="">extension</span><span style="" class=""> </span>Percentage<span style="" class="">:</span>Hashable<span style="" class=""> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">var</span> hashValue: <span style="color:#3495af" class="">Int</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175);background-color:rgb(255,255,255)" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#0433ff" class="">return</span><span style="" class=""> </span><span style="color:#0433ff" class="">self</span><span style="" class="">.</span>millionths<span style="" class="">.</span>hashValue</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">static</span> <span style="color:#0433ff" class="">func</span> == (lhs:<span style="color:#3495af" class="">Percentage</span>, rhs:<span style="color:#3495af" class="">Percentage</span>)-&gt;<span style="color:#3495af" class="">Bool</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> lhs.<span style="color:#3495af" class="">millionths</span> == rhs.<span style="color:#3495af" class="">millionths</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">}</div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255);min-height:14px" class=""><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175);background-color:rgb(255,255,255)" class=""><span style="color:#0433ff" class="">extension</span><span style="" class=""> </span>Percentage<span style="" class="">:</span>Comparable<span style="" class=""> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">static</span> <span style="color:#0433ff" class="">func</span> &lt; (lhs:<span style="color:#3495af" class="">Percentage</span>, rhs:<span style="color:#3495af" class="">Percentage</span>) -&gt; <span style="color:#3495af" class="">Bool</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> lhs.<span style="color:#3495af" class="">millionths</span> &lt; rhs.<span style="color:#3495af" class="">millionths</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">}</div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255);min-height:14px" class=""><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175);background-color:rgb(255,255,255)" class=""><span style="color:#0433ff" class="">extension</span><span style="" class=""> </span>Percentage<span style="" class=""> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175);background-color:rgb(255,255,255)" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="color:#0433ff" class="">static</span><span style="" class=""> </span><span style="color:#0433ff" class="">func</span><span style="" class=""> + (lhs:</span>Percentage<span style="" class="">, rhs:</span>Percentage<span style="" class="">)-&gt;</span>Percentage<span style="" class=""> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> <span style="color:#3495af" class="">Percentage</span>(storage: lhs.<span style="color:#3495af" class="">millionths</span> + rhs.<span style="color:#3495af" class="">millionths</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175);background-color:rgb(255,255,255)" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="color:#0433ff" class="">static</span><span style="" class=""> </span><span style="color:#0433ff" class="">func</span><span style="" class=""> - (lhs:</span>Percentage<span style="" class="">, rhs:</span>Percentage<span style="" class="">)-&gt;</span>Percentage<span style="" class=""> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">if</span> rhs &gt; lhs {<span style="color:#0433ff" class="">return</span> 0}</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> <span style="color:#3495af" class="">Percentage</span>(storage: lhs.<span style="color:#3495af" class="">millionths</span> - rhs.<span style="color:#3495af" class="">millionths</span>)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">static</span> <span style="color:#0433ff" class="">func</span> * (lhs:<span style="color:#3495af" class="">Percentage</span>, rhs:<span style="color:#3495af" class="">Double</span>)-&gt;<span style="color:#3495af" class="">Double</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> lhs.<span style="color:#3495af" class="">doubleValue</span> * rhs</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">static</span> <span style="color:#0433ff" class="">func</span> * (lhs:<span style="color:#3495af" class="">Double</span>, rhs:<span style="color:#3495af" class="">Percentage</span>)-&gt;<span style="color:#3495af" class="">Double</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> lhs * rhs.<span style="color:#3495af" class="">doubleValue</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175);background-color:rgb(255,255,255)" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="color:#0433ff" class="">static</span><span style="" class=""> </span><span style="color:#0433ff" class="">func</span><span style="" class=""> * (lhs:</span>Percentage<span style="" class="">, rhs:</span>CGFloat<span style="" class="">)-&gt;</span>CGFloat<span style="" class=""> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> lhs.<span style="color:#3495af" class="">cgfloatValue</span> * rhs</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175);background-color:rgb(255,255,255)" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="color:#0433ff" class="">static</span><span style="" class=""> </span><span style="color:#0433ff" class="">func</span><span style="" class=""> * (lhs:</span>CGFloat<span style="" class="">, rhs:</span>Percentage<span style="" class="">)-&gt;</span>CGFloat<span style="" class=""> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> lhs * rhs.<span style="color:#3495af" class="">cgfloatValue</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">static</span> <span style="color:#0433ff" class="">func</span> * (lhs:<span style="color:#3495af" class="">Percentage</span>, rhs:<span style="color:#3495af" class="">Num</span>)-&gt;<span style="color:#3495af" class="">Num</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> lhs.<span style="color:#3495af" class="">numValue</span> * rhs</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; <span style="color:#0433ff" class="">static</span> <span style="color:#0433ff" class="">func</span> * (lhs:<span style="color:#3495af" class="">Num</span>, rhs:<span style="color:#3495af" class="">Percentage</span>)-&gt;<span style="color:#3495af" class="">Num</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0433ff" class="">return</span> lhs * rhs.<span style="color:#3495af" class="">numValue</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin:0px;line-height:normal;background-color:rgb(255,255,255);min-height:14px" class=""><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175);background-color:rgb(255,255,255)" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="color:#0433ff" class="">static</span><span style="" class=""> </span><span style="color:#0433ff" class="">func</span><span style="" class=""> * (lhs:</span>Percentage<span style="" class="">, rhs:</span>Percentage<span style="" class="">)-&gt;</span>Percentage<span style="" class=""> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175);background-color:rgb(255,255,255)" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#0433ff" class="">return</span><span style="" class=""> </span>Percentage<span style="" class="">(lhs.</span>decimalValue<span style="" class=""> * rhs.</span>decimalValue<span style="" class="">)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;<br class="m_-2401119500926847804webkit-block-placeholder"></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class="">}</div></div><div class=""><div class="h5"><div class=""><br class=""></div><div class=""><br class=""></div><div class="">&nbsp;<br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 13, 2018, at 6:26 PM, Jonathan Hull via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-2401119500926847804Apple-interchange-newline"><div class=""><div class="">Hi Evolution,<br class=""><br class="">I was wondering if we would consider adding a percentage type to Swift.&nbsp; This would be a type with a value between 0 &amp; 1.<br class=""><br class="">I know we can and do use doubles or floats for this now, but there really is a semantic difference between most parameters that take a value between 0 &amp; 1 and those that take any floating point value.&nbsp; It would be nice to have a type that semantically means that the value is from 0 to 1.<br class=""><br class="">It could even just wrap a Double for speed (in my own code I wrap a UInt64 for decimal accuracy… and to avoid issues around comparisons).<br class=""><br class="">Thanks,<br class="">Jon<br class="">______________________________<wbr class="">_________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/<wbr class="">mailman/listinfo/swift-<wbr class="">evolution</a><br class=""></div></div></blockquote></div><br class=""></div></div></div></div><br class="">______________________________<wbr class="">_________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/<wbr class="">mailman/listinfo/swift-<wbr class="">evolution</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>