Sky Yin
1/15/2006 2:30:00 AM
Thanks, Joe and David. Although I don't quite understand the science behind
that, add a bit more ".to_i" is enough for me.
On 1/14/06, David Vallner <david@vallner.net> wrote:
>
> On Sat, 14 Jan 2006 16:52:41 +0100, Sky Yin <sky.yin@gmail.com> wrote:
>
> >
> > Basic math tells me 2/1 = 2, so what's the point of returning Rational
> > instead of Fixnum here?
> >
>
> Because the code calculates in rationals?
>
> You might want to 'require "mathn"' on the beginning of the script if it
> bugs you, the module causes Ruby math to work more... err...
> mathemathically. E.g.:
>
> irb(main):001:0> Rational(2, 1)
> => Rational(2, 1)
> irb(main):002:0> require "mathn"
> => true
> irb(main):003:0> Rational(2, 1)
> => 2
>
> As always after doing deeper magic, be on the lookout for bugs the module
> could introduce.
>
> David Vallner
>
>