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

ruby-changes:5644

From: tadf <ko1@a...>
Date: Fri, 13 Jun 2008 22:02:53 +0900 (JST)
Subject: [ruby-changes:5644] Ruby:r17151 (trunk): * rational.c (nurat_equal_p): Rational(0,x) and 0 are equivalent,

tadf	2008-06-13 21:59:22 +0900 (Fri, 13 Jun 2008)

  New Revision: 17151

  Modified files:
    trunk/ChangeLog
    trunk/rational.c

  Log:
    * rational.c (nurat_equal_p): Rational(0,x) and 0 are equivalent,
      anyway.
    


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=17151&r2=17150&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/rational.c?r1=17151&r2=17150&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 17150)
+++ ChangeLog	(revision 17151)
@@ -1,3 +1,8 @@
+Fri Jun 13 21:55:48 2008  Tadayoshi Funaba  <tadf@d...>
+
+	* rational.c (nurat_equal_p): Rational(0,x) and 0 are equivalent,
+	  anyway.
+
 Fri Jun 13 21:26:39 2008  Tadayoshi Funaba  <tadf@d...>
 
 	* complex.c (string_to_c, nucomp_s_convert): preserve the current
Index: rational.c
===================================================================
--- rational.c	(revision 17150)
+++ rational.c	(revision 17151)
@@ -865,6 +865,9 @@
 	{
 	    get_dat1(self);
 
+	    if (f_zero_p(dat->num) && f_zero_p(other))
+		return Qtrue;
+
 	    if (!FIXNUM_P(dat->den))
 		return Qfalse;
 	    if (FIX2LONG(dat->den) != 1)
@@ -879,6 +882,9 @@
 	{
 	    get_dat2(self, other);
 
+	    if (f_zero_p(adat->num) && f_zero_p(bdat->num))
+		return Qtrue;
+
 	    return f_boolcast(f_equal_p(adat->num, bdat->num) &&
 			      f_equal_p(adat->den, bdat->den));
 	}

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

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