diff options
author | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-06-06 01:04:11 +0000 |
---|---|---|
committer | mrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-06-06 01:04:11 +0000 |
commit | febc42d05c6b8a401fff2361bf03fe338eb4d1b0 (patch) | |
tree | 0f067d8458ad54561a41f7d19c330f3b73fcbf4d /numeric.c | |
parent | b43d6331cbf218583ddd1db3a388e5b8d46362f7 (diff) | |
download | ruby-febc42d05c6b8a401fff2361bf03fe338eb4d1b0.tar.gz |
* numeric.c (num_quo): should return a Float for a Float argument.
[ruby-dev:44710] [Bug #5515]
* test/ruby/test_fixnum.rb: Add an assertion for the above change.
* test/ruby/test_bignum.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -371,29 +371,34 @@ num_uminus(VALUE num) /* * call-seq: - * num.quo(numeric) -> real + * num.fdiv(numeric) -> float * - * Returns most exact division (rational for integers, float for floats). + * Returns float division. */ static VALUE -num_quo(VALUE x, VALUE y) +num_fdiv(VALUE x, VALUE y) { - return rb_funcall(rb_rational_raw1(x), '/', 1, y); + return rb_funcall(rb_Float(x), '/', 1, y); } /* * call-seq: - * num.fdiv(numeric) -> float + * num.quo(int_or_rat) -> rat + * num.quo(flo) -> flo * - * Returns float division. + * Returns most exact division (rational for integers, float for floats). */ static VALUE -num_fdiv(VALUE x, VALUE y) +num_quo(VALUE x, VALUE y) { - return rb_funcall(rb_Float(x), '/', 1, y); + if (RB_TYPE_P(y, T_FLOAT)) { + return num_fdiv(x, y); + } + + return rb_funcall(rb_rational_raw1(x), '/', 1, y); } |