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

ruby-changes:26357

From: tadf <ko1@a...>
Date: Sat, 15 Dec 2012 18:25:27 +0900 (JST)
Subject: [ruby-changes:26357] tadf:r38408 (trunk): * rational.c (f_round_common): should check overflow.

tadf	2012-12-15 18:25:13 +0900 (Sat, 15 Dec 2012)

  New Revision: 38408

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

  Log:
    * rational.c (f_round_common): should check overflow.

  Modified files:
    trunk/ChangeLog
    trunk/rational.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38407)
+++ ChangeLog	(revision 38408)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Dec 15 18:24:21 2012  Tadayoshi Funaba  <tadf@d...>
+
+	* rational.c (f_round_common): should check overflow.
+
 Sat Dec 15 18:00:00 2012  Tadayoshi Funaba  <tadf@d...>
 
 	* ratioanl.c (float_rationalize): reduced.
Index: rational.c
===================================================================
--- rational.c	(revision 38407)
+++ rational.c	(revision 38408)
@@ -1210,6 +1210,12 @@ f_round_common(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/rational.c#L1210
     b = f_expt10(n);
     s = f_mul(self, b);
 
+    if (k_float_p(s)) {
+	if (f_lt_p(n, ZERO))
+	    return ZERO;
+	return self;
+    }
+
     s = (*func)(s);
 
     s = f_div(f_rational_new_bang1(CLASS_OF(self), s), b);

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

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