<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=""><div class="">If Swift’s Ints may go up to 2048 bits, I’d agree that they probably cover most cases. That’s not to say a big int would be useless, just that I think it should be separate, meant to be used by those who actually need it rather than interfering with normal Int logic, which is likely to be used more often.</div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Dec 4, 2015, at 2:45 AM, Austin Zheng &lt;<a href="mailto:austinzheng@gmail.com" class="">austinzheng@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Clojure also performs automatic reduction of rational numbers. However, the source code seems to indicate that reduction is built into the definitions of the methods that perform arithmetic on rational numbers, and the "Ratio" class that implements rational number support does not do any reduction itself.<div class=""><br class=""></div><div class="">(c.f.&nbsp;<a href="https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Numbers.java" class="">https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Numbers.java</a>, ll. 350-364, 704-727, et al)</div><div class=""><br class=""></div><div class="">From a semantic standpoint, I would be very surprised if e.g. 2/6 and 1/3 were not considered equal, or for that matter if they weren't completely interchangeable.</div><div class=""><br class=""></div><div class="">- Austin</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Dec 3, 2015 at 11:21 PM, Kevin Ballard <span dir="ltr" class="">&lt;<a href="mailto:kevin@sb.org" target="_blank" class="">kevin@sb.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"><span class="">On Dec 3, 2015, at 9:48 PM, Dmitri Gribenko &lt;<a href="mailto:gribozavr@gmail.com" class="">gribozavr@gmail.com</a>&gt; wrote:<br class="">
&gt;<br class="">
&gt;&gt; A good invariant for Rationals might be having them always<br class="">
&gt;&gt; represented in the most simplified form - for example, Rational(2, 6) should<br class="">
&gt;&gt; be represented internally as 1/3 when constructed.<br class="">
&gt;<br class="">
&gt; This has performance tradeoffs.&nbsp; What do other libraries and languages do?<br class="">
<br class="">
</span>I know Haskell always reduces Rationals to their reduced form. This does have performance implications, but not doing so has surprising consequences for operations you perform on them. For example, it’s reasonable to expect that Rational(2,6) == Rational(1,3), but implementing that without reduced Rationals pretty much requires reducing them on the fly. The alternative, of saying they’re not equal, would probably surprise most people.<br class="">
<span class="HOEnZb"><font color="#888888" class=""><br class="">
-Kevin Ballard</font></span></blockquote></div><br class=""></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=LFwSuj9FMv8p5lHRk78JpoTG6TdqPOb6ZXyNv3YIC3zbsYVMjmdmr5VThSefbfXpPrbZx7xsnVy7iEuQSgFeV1AoX5Xhg4NX4vZr67ifQa6wE-2FUrWA56WTm-2BzPC-2FGAYPvq6ksSk7qqNCp2LOP2ijoVtwp-2BScpwvaZI0CJSpyD7xF4JhZc1VPcj24Ows4RGu0sJ0evpSTWLJCI7HEQWTxu7RnLqdMupWkVNindk2iNZA-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=""></body></html>