summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-27 12:47:14 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-27 12:47:14 +0000
commit8a3f0ce44aaa67675f8da477b11c17af767879ed (patch)
tree519c7e4ee87b52afc7b9b6c5996b131d540847be
parent5342ed85f9c0d130d15540e042f739255ca05ab5 (diff)
* numeric.c (num_fdiv): fallback to_f should always return float
result. should not use #quo that may return rational. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog3
-rw-r--r--numeric.c16
2 files changed, 18 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 5f9eb1e1de..296ce35b2f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,6 +28,9 @@ Tue May 27 15:36:27 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* numeric.c (check_uint, rb_num2fix, int_chr): ditto.
+ * numeric.c (num_fdiv): fallback to_f should always return float
+ result. should not use #quo that may return rational.
+
Tue May 27 13:14:53 2008 Akinori MUSHA <knu@iDaemons.org>
* enum.c (enum_to_a): Pass arguments through to #each().
diff --git a/numeric.c b/numeric.c
index 95e44a2ec8..ea931b2275 100644
--- a/numeric.c
+++ b/numeric.c
@@ -260,6 +260,20 @@ num_quo(VALUE x, VALUE y)
}
+/*
+ * call-seq:
+ * num.fdiv(numeric) => float
+ *
+ * Returns float division.
+ */
+
+static VALUE
+num_fdiv(VALUE x, VALUE y)
+{
+ return rb_funcall(rb_Float(x), '/', 1, y);
+}
+
+
static VALUE num_floor(VALUE num);
/*
@@ -3101,7 +3115,7 @@ Init_Numeric(void)
rb_define_method(rb_cNumeric, "<=>", num_cmp, 1);
rb_define_method(rb_cNumeric, "eql?", num_eql, 1);
rb_define_method(rb_cNumeric, "quo", num_quo, 1);
- rb_define_method(rb_cNumeric, "fdiv", num_quo, 1);
+ rb_define_method(rb_cNumeric, "fdiv", num_fdiv, 1);
rb_define_method(rb_cNumeric, "div", num_div, 1);
rb_define_method(rb_cNumeric, "divmod", num_divmod, 1);
rb_define_method(rb_cNumeric, "modulo", num_modulo, 1);