From: Mark Hubbart Date: 2004-09-16T08:52:58+09:00 Subject: Re: Bignum Troubles On Sep 15, 2004, at 4:12 PM, James Edward Gray II wrote: > On Sep 15, 2004, at 6:05 PM, Robert Klemme wrote: > >> Just one other remark, there is a lib that changes the semantics of >> int division. I don't remember the name though. So 5 / 3 is not >> always a Fixnum. > > Is this a standard lib? Yes, Rational numbers are defined in rational.rb. Just require 'rational'. 'mathn', also in the stdlib, includes 'rational', 'complex' and 'matrix', and adds a little extra glue (as well as implementing a "Prime" class). Aside: It's amazing what you can find in the stdlib; when I was first getting familiar with Ruby, I kept getting surprised at what I found there :) It's also amazing how nicely things tie in; all the new Numeric types are automatically created in appropriate circumstances: require 'mathn' ==>true 5/8 ==>5/8 5/8*2 ==>5/4 5/8+4/3 ==>47/24 Math.sqrt -4 ==>Complex(0, 2) cheers, Mark > James Edward Gray II > >