Reading the source, Ratios are actually represented as java.math.BigIntegerobjects. ( https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang /Ratio.java)
Asking for denominator and numerator returns these values directly. user=> (class (denominator (/ 1 2))) java.math.BigInteger user=> (class (numerator (/ 1 2))) java.math.BigInteger Following the source, conversion happens in the Numbers.divide(BigInteger, BigInteger) method: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang /Numbers.java#L342 (called from https://github.com/clojure/clojure/blob/master/src/jvm/clojure/ lang/Numbers.java#L670) Cheers, Alf On 1 April 2013 23:57, Alan Thompson <thompson2...@gmail.com> wrote: > Just read about this in "Clojure Programming" (Emerick) p428: > clojure.lang.BigInt is different than java.lang.BigInteger, in that BigInt > uses 64-bit primitive longs under the covers to keep performance up if the > value will fit within the range of a long. So for "normal" sized values, > it doesn't have the overhead of the arbitrary-precision type. But, the > extra precision is there if you need it later on in a calculation. > Alan Thompson > > > > On Mon, Apr 1, 2013 at 2:43 PM, Gary Verhaegen > <gary.verhae...@gmail.com>wrote: > >> That's because ratios are intended to get you arbitrary precision. >> That would not work so well if they used Longs for their numerator and >> denominator. >> >> On 29 March 2013 14:11, Peter Mancini <peter.manc...@gmail.com> wrote: >> > (class 1) java.lang.Long ;check! >> > (class (* (/ 1 255) 254)) clojure.lang.Ratio ;check! >> > (class (* (/ 1 255) 255)) clojure.lang.BigInt ;WAT? >> > >> > Should not example 3 and example 1 end up the same? (Noob question, I >> know, >> > but this didn't make sense to me and I thought I was doing something >> wrong >> > when I saw 1N coming back.) >> > > > -- > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.