Hi,

In message "[ruby-talk:18732] Numbers classes.. Rational number? [was: Ruby as opposed to Python?]"
    on 01/07/29, Kent Dahl <kentda / stud.ntnu.no> writes:


|Is there any Rational classes out there? I scanned thru the RAA before I
|wrote my current hack, but couldn't see any.

It is bundled in the standard distribution (well, I should finish
"Ruby Essentials" early).

  require "rational"

  a = Rational(5,2)

And Ruby can even provide Jean Michel's proposal already.

|>    5/2==5/2
|> (the Rational number 5/2). Ruby has big ints, it should also
|> have Rationals :)

  require "mathn"

  p 5/2  # => 5/2

In message "[ruby-talk:18734] Re: Numbers classes.. Rational number? [was: Ruby as opposed to Python?]"
    on 01/07/29, Kero van Gelder <kero / d4050.upc-d.chello.nl> writes:

|which raises the question:
|
|  Rational(5, 2) / 3.0  => Rational? Float?

Float.

  require "mathn"

  p 5/2/3.0  # => 0.8333333333

							matz.