From: "Florian G. Pflug" Date: 2001-07-29T23:38:14+09:00 Subject: [ruby-talk:18744] Re: Numbers classes.. Rational number? [was: Ruby as opposed to Python?] On Sun, Jul 29, 2001 at 09:58:02PM +0900, Kero van Gelder wrote: > 12345678901234567890 / 1.0 => 1.23456789e+19 > > which actually looses accuracy, by automatically converting to float, > instead of BigNum. This would be an argument to drop automatic > conversion for floats. You could still convert automatically with > Numerics and Rationals, since you loose nothing (and should expect a > Rational anyway). I like the idea of built-in rationals. Since the difference between rationals and ints is much smaller than between rations and floats, I believe fully automatic conversion between ints and rationals makes more sense than between ints(rationals) and reals. Rationals of course should automatically convert themselfes to Fixnums (or Bignums) if possible. e.g 1/2 = Rational(1,2) Rational(1,2) * 2 = Fixnum(1) For floats I am unsure what 1/2.0 should give. Since the /-operator is a member function of Int in that case, one could argue that the result should be 1 (or 0?). This would mean that "float on the left side gives float for the result". For division this _could_ be ok, but for multiplication its crazy. 1.0 * 12345678987654321 would give a float, thus losing accuracy, but 12345678987654321 * 1.0 would give an int. Maybe there this be an extra set of operators for float? kind of like: /., *. greetings, Florian Pflug