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

ruby-changes:12200

From: tadf <ko1@a...>
Date: Sun, 28 Jun 2009 23:39:47 +0900 (JST)
Subject: [ruby-changes:12200] Ruby:r23884 (trunk): * complex.c (nucomp_div): raises ZeroDivisionError immediately

tadf	2009-06-28 23:39:31 +0900 (Sun, 28 Jun 2009)

  New Revision: 23884

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23884

  Log:
    * complex.c (nucomp_div): raises ZeroDivisionError immediately
      when the given second argument is zero.
    * rational.c (nurat_fdiv): never raise even if the given second
      argument is zero.
    
    * rational.c (rb_raise_zerodiv): changed the message (zero to 0).

  Modified files:
    trunk/ChangeLog
    trunk/complex.c
    trunk/rational.c

Index: complex.c
===================================================================
--- complex.c	(revision 23883)
+++ complex.c	(revision 23884)
@@ -727,6 +727,8 @@
     return rb_num_coerce_bin(self, other, id);
 }
 
+#define rb_raise_zerodiv() rb_raise(rb_eZeroDivError, "divided by 0")
+
 /*
  * call-seq:
  *    cmp / numeric     ->  complex
@@ -742,6 +744,8 @@
 static VALUE
 nucomp_div(VALUE self, VALUE other)
 {
+    if (f_zero_p(other))
+	rb_raise_zerodiv();
     return f_divide(self, other, f_quo, id_quo);
 }
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 23883)
+++ ChangeLog	(revision 23884)
@@ -1,3 +1,13 @@
+Sun Jun 28 23:32:11 2009  Tadayoshi Funaba  <tadf@d...>
+
+	* complex.c (nucomp_div): raises ZeroDivisionError immediately
+	  when the given second argument is zero.
+
+	* rational.c (nurat_fdiv): never raise even if the given second
+	  argument is zero.
+
+	* rational.c (rb_raise_zerodiv): changed the message (zero to 0).
+
 Sun Jun 28 22:25:07 2009  Tadayoshi Funaba  <tadf@d...>
 
 	* complex.c (nucomp_expt): convert to a float when the given power
Index: rational.c
===================================================================
--- rational.c	(revision 23883)
+++ rational.c	(revision 23884)
@@ -321,7 +321,7 @@
     return nurat_s_new_internal(klass, ZERO, ONE);
 }
 
-#define rb_raise_zerodiv() rb_raise(rb_eZeroDivError, "divided by zero")
+#define rb_raise_zerodiv() rb_raise(rb_eZeroDivError, "divided by 0")
 
 #if 0
 static VALUE
@@ -867,6 +867,8 @@
 static VALUE
 nurat_fdiv(VALUE self, VALUE other)
 {
+    if (f_zero_p(other))
+	return f_div(self, f_to_f(other));
     return f_to_f(f_div(self, other));
 }
 

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

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