1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* numeric.c (num_step): treat infinite step specially.

[ruby-dev:37157] fix: #781.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2008-11-24 18:40:07 +00:00
parent 4671724697
commit 012fee9476
2 changed files with 14 additions and 4 deletions

View file

@ -1,3 +1,8 @@
Tue Nov 25 03:26:04 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* numeric.c (num_step): treat infinite step specially.
[ruby-dev:37157] fix: #781.
Tue Nov 25 01:23:25 2008 Tadayoshi Funaba <tadf@dotrb.org>
* lib/date/format.rb (strftime): ignores '_' flag for %[LN].

View file

@ -1503,10 +1503,15 @@ num_step(int argc, VALUE *argv, VALUE from)
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 {