diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-09-15 17:13:51 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-09-15 17:13:51 +0000 |
commit | 22420b14536c02697b37149bd27b8f6a3d07e8a8 (patch) | |
tree | 15139261127fad0f4327b26bbb31be4b87dc6ab0 /numeric.c | |
parent | 6ca73ab90c863aac6a690d340ffd37ef0fd45162 (diff) |
* numeric.c (ruby_float_step): Avoid error on i386 and amd64.
Patch by Vit Ondruch. Issue #4576.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -1683,6 +1683,7 @@ ruby_float_step(VALUE from, VALUE to, VALUE step, int excl) double unit = NUM2DBL(step); double n = (end - beg)/unit; double err = (fabs(beg) + fabs(end) + fabs(end-beg)) / fabs(unit) * epsilon; + double im = 0.0; long i; if (isinf(unit)) { @@ -1691,7 +1692,8 @@ ruby_float_step(VALUE from, VALUE to, VALUE step, int excl) else { if (err>0.5) err=0.5; n = floor(n + err); - if (!excl || ((long)n)*unit+beg < end) n++; + im = ((long)n)*unit+beg; + if (!excl || im < end) n++; for (i=0; i<n; i++) { rb_yield(DBL2NUM(i*unit+beg)); } |