summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-07 04:14:57 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-07 04:14:57 +0000
commitfa161103263f001ba009cecfbc25ed336757ede7 (patch)
tree0677b0d96fbcc241b80054a32859f4c8131438c5 /numeric.c
parentf7b3f1c528260e50db430a0dcd3678d447308d89 (diff)
* 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
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c17
1 files changed, 4 insertions, 13 deletions
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 <code>Numeric#/</code>, 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,24 +2214,17 @@ 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 <i>fix</i> by
* <i>numeric</i>.
*
- * 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)
{
if (FIXNUM_P(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);