(2011/09/17 9:07), Tanaka Akira wrote:
> So my understanding of this problem is that no one implemented
> proper exclude_end support with well considered float errors, yet.

In my current understanding, the error is
fabs(beg) * epsilon + fabs(unit) * epsilon * n + fabs(end) * epsilon
= (fabs(beg) + fabs(end) + fabs(end-beg)) * epsilon
// ignore error over unit*n -> end-beg
But the correct error may be less than it.

diff --git a/numeric.c b/numeric.c
index 18f5e1c..459e209 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1691,7 +1691,9 @@ 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++;
+           err = (fabs(beg) + fabs(end) + fabs(end-beg)) * epsilon;
+           if (err>0.5) err=0.5;
+           if (!excl || (long)n*unit+beg+err < end) n++;
            for (i=0; i<n; i++) {
                rb_yield(DBL2NUM(i*unit+beg));
            }

-- 
NARUSE, Yui  <naruse / airemix.jp>