summaryrefslogtreecommitdiffstats
path: root/lib/rational.rb
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-19 16:01:06 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-19 16:01:06 +0000
commit047849e878344cedf991a20525c955495b4268fe (patch)
treee5b382e3e6dc23c0eef00a2da9fb50c0e2281495 /lib/rational.rb
parent13e32804c892bc8f4171f4c9cd73b7fed7645dc3 (diff)
downloadruby-047849e878344cedf991a20525c955495b4268fe.tar.gz
ruby-047849e878344cedf991a20525c955495b4268fe.tar.xz
ruby-047849e878344cedf991a20525c955495b4268fe.zip
* io.c (io_close): call rb_io_close() directly if io is a T_FILE
object. [ruby-dev:27156] * file.c (file_expand_path): allow pathnames to expand. [ruby-dev:27152] * numeric.c (Init_Numeric): should define Fixnum#div. [ruby-dev:27129] * file.c (rb_thread_flock): wrap flock(2) by TRAP_BEG and TRAP_END. [ruby-dev:27122] * file.c (rb_file_join): call FilePathValue() to all Pathnames to join. [ruby-dev:27127] * file.c (rb_get_path): call StringValueCStr() to ensure no nul bytes in path strings. * gc.c (garbage_collect): need value for return. [ruby-dev:27127] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@9236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rational.rb')
-rw-r--r--lib/rational.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/rational.rb b/lib/rational.rb
index 224100485..f4570bd30 100644
--- a/lib/rational.rb
+++ b/lib/rational.rb
@@ -37,6 +37,7 @@
#
def Rational(a, b = 1)
+ p [:Rational, a, b]
if a.kind_of?(Rational) && b == 1
a
else
@@ -54,9 +55,13 @@ class Rational < Numeric
num = -num
den = -den
end
+ p [:reduce, num, den]
gcd = num.gcd(den)
+ p [:div1, num, num.class, gcd]
num = num.div(gcd)
+ p [:div2, den, gcd]
den = den.div(gcd)
+ p [:gcd=, gcd]
if den == 1 && defined?(Unify)
num
else
@@ -333,6 +338,7 @@ end
class Fixnum
undef quo
def quo(other)
+ p [:quo, self, other]
Rational.new!(self,1) / other
end
alias rdiv quo