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

ruby-changes:8812

From: matz <ko1@a...>
Date: Tue, 25 Nov 2008 03:40:26 +0900 (JST)
Subject: [ruby-changes:8812] Ruby:r20348 (trunk): * numeric.c (num_step): treat infinite step specially.

matz	2008-11-25 03:40:07 +0900 (Tue, 25 Nov 2008)

  New Revision: 20348

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

  Log:
    * numeric.c (num_step): treat infinite step specially.
      [ruby-dev:37157] fix: #781.

  Modified files:
    trunk/ChangeLog
    trunk/numeric.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 20347)
+++ ChangeLog	(revision 20348)
@@ -1,3 +1,8 @@
+Tue Nov 25 03:26:04 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* numeric.c (num_step): treat infinite step specially.
+	  [ruby-dev:37157] fix: #781.
+
 Tue Nov 25 01:23:25 2008  Tadayoshi Funaba  <tadf@d...>
 
 	* lib/date/format.rb (strftime): ignores '_' flag for %[LN].
Index: numeric.c
===================================================================
--- numeric.c	(revision 20347)
+++ numeric.c	(revision 20348)
@@ -1503,11 +1503,16 @@
 	double err = (fabs(beg) + fabs(end) + fabs(end-beg)) / fabs(unit) * epsilon;
 	long i;
 
-	if (err>0.5) err=0.5;
-	n = floor(n + err) + 1;
-	for (i=0; i<n; i++) {
-	    rb_yield(DBL2NUM(i*unit+beg));
+	if (isinf(unit)) {
+	    if (unit > 0) rb_yield(DBL2NUM(beg));
 	}
+	else {
+	    if (err>0.5) err=0.5;
+	    n = floor(n + err) + 1;
+	    for (i=0; i<n; i++) {
+		rb_yield(DBL2NUM(i*unit+beg));
+	    }
+	}
     }
     else {
 	VALUE i = from;

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

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