From fa161103263f001ba009cecfbc25ed336757ede7 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 7 May 2008 04:14:57 +0000 Subject: * bignum.c (rb_big_fdiv): flo.fdiv(NaN) should result NaN. * numeric.c (num_quo): renamed and moved from bignum.c. [ruby-dev:34582] * bignum.c (rb_big_fdiv): update RDoc description * rational.c (nurat_s_new_m): small refactoring. * bignum.c (rb_big2dbl): no need for forceful warning when converting to float. overflow is a nature of float values. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- numeric.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'numeric.c') diff --git a/numeric.c b/numeric.c index 0ae4bb0827..cc2f3f2059 100644 --- a/numeric.c +++ b/numeric.c @@ -249,15 +249,14 @@ num_uminus(VALUE num) /* * call-seq: * num.quo(numeric) => result - * num.fdiv(numeric) => result * - * Equivalent to Numeric#/, but overridden in subclasses. + * Returns most exact division (rational for integers, float for floats). */ static VALUE num_quo(VALUE x, VALUE y) { - return rb_funcall(x, '/', 1, y); + return rb_funcall(rb_rational_raw1(x), '/', 1, y); } @@ -2215,23 +2214,16 @@ fixdivmod(long x, long y, long *divp, long *modp) /* * call-seq: - * fix.quo(numeric) => float * fix.fdiv(numeric) => float * * Returns the floating point result of dividing fix by * numeric. * - * 654321.quo(13731) #=> 47.6528293642124 - * 654321.quo(13731.24) #=> 47.6519964693647 + * 654321.fdiv(13731) #=> 47.6528293642124 + * 654321.fdiv(13731.24) #=> 47.6519964693647 * */ -static VALUE -fix_quo(VALUE x, VALUE y) -{ - return rb_funcall(rb_rational_raw1(x), '/', 1, y); -} - static VALUE fix_fdiv(VALUE x, VALUE y) { @@ -3225,7 +3217,6 @@ Init_Numeric(void) rb_define_method(rb_cFixnum, "%", fix_mod, 1); rb_define_method(rb_cFixnum, "modulo", fix_mod, 1); rb_define_method(rb_cFixnum, "divmod", fix_divmod, 1); - rb_define_method(rb_cFixnum, "quo", fix_quo, 1); rb_define_method(rb_cFixnum, "fdiv", fix_fdiv, 1); rb_define_method(rb_cFixnum, "**", fix_pow, 1); -- cgit v1.2.3