diff options
author | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-12 11:46:40 +0000 |
---|---|---|
committer | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-12 11:46:40 +0000 |
commit | 2014cde103124bc8ec14b8b3d2b75062ac2b3c9a (patch) | |
tree | 372546bcea5a90bcd1aba0d556742ee09f20add7 /numeric.c | |
parent | 39ec6fb8b3d9ab83a9155efe56d087bbd3081377 (diff) | |
download | ruby-2014cde103124bc8ec14b8b3d2b75062ac2b3c9a.tar.gz ruby-2014cde103124bc8ec14b8b3d2b75062ac2b3c9a.tar.xz ruby-2014cde103124bc8ec14b8b3d2b75062ac2b3c9a.zip |
* numeric.c (fix_divide): added an entry to rational.
* rational.c (rb_rational_reciprocal): added.
* complex.c (f_reciprocal): added.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@24035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -2268,6 +2268,8 @@ fix_fdiv(VALUE x, VALUE y) } } +VALUE rb_rational_reciprocal(VALUE x); + static VALUE fix_divide(VALUE x, VALUE y, ID op) { @@ -2295,6 +2297,10 @@ fix_divide(VALUE x, VALUE y, ID op) return rb_dbl2big(floor(div)); } } + case T_RATIONAL: + if (op == '/' && FIX2LONG(x) == 1) + return rb_rational_reciprocal(y); + return rb_funcall(rb_rational_new1(x), op, 1, y); default: return rb_num_coerce_bin(x, y, op); } |