summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-16 06:44:59 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-16 06:44:59 +0000
commitfd47fed2699a53cdeb26d204a6fb6a4b75db42ac (patch)
treecf5c0f68698c3c370d32ab824563903fe7b6d6eb /numeric.c
parent23d472165f401e28bc2128f74a964c438cf3ced4 (diff)
* numeric.c (ruby_float_step): Avoid error on i386 and amd64.
Patch by Vit Ondruch. Issue #4576 [rubyspec:a9525edcd] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/numeric.c b/numeric.c
index 18f5e1cd1a..1701d1005e 100644
--- a/numeric.c
+++ b/numeric.c
@@ -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));
}