[前][次][番号順一覧][スレッド一覧]

ruby-changes:5154

From: matz <ko1@a...>
Date: Tue, 27 May 2008 21:47:37 +0900 (JST)
Subject: [ruby-changes:5154] Ruby:r16649 (trunk): * numeric.c (num_fdiv): fallback to_f should always return float

matz	2008-05-27 21:47:14 +0900 (Tue, 27 May 2008)

  New Revision: 16649

  Modified files:
    trunk/ChangeLog
    trunk/numeric.c

  Log:
    * numeric.c (num_fdiv): fallback to_f should always return float
      result.  should not use #quo that may return rational.

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/numeric.c?r1=16649&r2=16648&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16649&r2=16648&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 16648)
+++ ChangeLog	(revision 16649)
@@ -28,6 +28,9 @@
 
 	* 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@i...>
 
 	* enum.c (enum_to_a): Pass arguments through to #each().
Index: numeric.c
===================================================================
--- numeric.c	(revision 16648)
+++ numeric.c	(revision 16649)
@@ -260,6 +260,20 @@
 }
 
 
+/*
+ *  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 @@
     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);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]