<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="">While I agree that a Rational type, one that would preserve quotient and denominator info, would be very nice, I think that it's more fit for a Math framework.<div class="">If we're just talking about a type that holds precise decimal info, I think making NSDecimal (planned to be renamed as Decimal in the future) usable is what we should do.</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 7 Dec 2015, at 10:28, T.J. Usiyan via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I'm all for a stdlib Rational Type. I've written one as well and would be glad not to have to include it as a dependency everywhere.<div class="">TJ</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Dec 7, 2015 at 1:31 PM, Harlan Haskins 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="">If Swift 3 is going to focus on re-thinking the Numerics in the system, it might be worth considering adding a Fraction (or Rational) type to the standard library. This, coupled with an arbitrary-precision integer type, would be a great way to handle arbitrary-precision decimal arithmetic, and can alleviate almost all the pain points of floating-point math.<div class=""><br class=""></div><div class="">There exist now some really nice implementations of Fractions, but the ones I’ve seen haven’t been implemented fully generically.</div><div class="">My favorite is this one: <a href="https://gist.github.com/JadenGeller/5e80ebf32442acc62e8e" target="_blank" class="">https://gist.github.com/JadenGeller/5e80ebf32442acc62e8e</a></div><div class=""><br class=""></div><div class="">I’d love to see some standard library support with rock-solid, fast implementations of all the common algorithms (GCD, LCD, LCM, reduction, etc) and good conformance to the builtin integer protocols. Maybe even <font face="Menlo" class="">FloatLiteralConvertible</font>, too, with some logic for converting rational floats.</div><div class=""><br class=""></div><div class="">Thoughts?</div><div class=""><br class=""></div><div class="">- Harlan Haskins</div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=3FGfocPbgxkNkmje7djckg9Iw-2BGYY3X6RxJ1tkUXKCr1mGWLtle38JhdUCkzNvAFKca8BI2IZiTedPLguLDg1TtEYLXGYWH-2BewJkLb-2BjDBcqBgL2BYa-2Bl3NtT5XEQq3q0-2BrFJrSHllGvw98ZC-2Fu4xrlfCCw4-2BsieLIEsY7P-2BUNjLXPzadS22jPmYlmgrNHQz8IRukh5taYbBZlJSrd3mryYE4ngwTngf508M5-2BYT-2Bk8-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important" class="">
</div>
<br 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/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=UNDxqBUDZDpZmPmXfIKeZ1UxMq-2BwsURX5ulfpb2jFAb7Fr-2B9NviBmWgtjjOe77nZqOVkc0JgAcimPmGQF3PbEdSjl-2FJaFCTZJoQtlKKgosTz7m-2Bt1OsZlC3LCpn25QNlcB5ENr1EsexNJTmW4c55LBH4f7gxiQolTIzTGk0OhfAJSonAk3b86sTgylPlQ0hZxqmG5MqpNote2sTDFadENU5oAiPss0EKq9rae5-2FjeYY-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>