summaryrefslogtreecommitdiffstats
path: root/numeric.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-06 16:48:51 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-06 16:48:51 +0000
commitf91f57614ba8bc3a24e37511ad5ca2889e9370d6 (patch)
treeb366bd85f807cb806160b0b67393d2255f554bc3 /numeric.c
parent12cb0d286cf6ebab0aa16f38cfde6b1f3847b4f8 (diff)
downloadruby-f91f57614ba8bc3a24e37511ad5ca2889e9370d6.tar.gz
ruby-f91f57614ba8bc3a24e37511ad5ca2889e9370d6.tar.xz
ruby-f91f57614ba8bc3a24e37511ad5ca2889e9370d6.zip
* numeric.c (num_step): remove epsilon; add margin of 0.5, to make
"1.1.step(1.5,0.1)" to work (third try). git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/numeric.c b/numeric.c
index b5d275f89..afc359064 100644
--- a/numeric.c
+++ b/numeric.c
@@ -905,14 +905,13 @@ num_step(argc, argv, from)
}
}
else if (TYPE(from) == T_FLOAT || TYPE(to) == T_FLOAT || TYPE(step) == T_FLOAT) {
- const double epsilon = DBL_EPSILON * 2;
double beg = NUM2DBL(from);
double end = NUM2DBL(to);
double unit = NUM2DBL(step);
double n = (end - beg)/unit;
long i;
- n = floor(n + n*epsilon) + 1;
+ n = n + 0.5;
for (i=0; i<n; i++) {
rb_yield(rb_float_new(i*unit+beg));
}