2011/9/17 Yusuke ENDOH <mame / tsg.ne.jp>:

> Maybe this "consideration" causes the following behavior:
>
>  p (1.0..12.7).step(1.3).all? {|n| n <= 12.7 }  #=> false
>  p (1.0..12.7).step(1.3).to_a
>    #=> [1.0, 2.3, 3.6, 4.9, 6.2, 7.5, 8.8, 10.1, 11.4, 12.700000000000001]
>
> Is this ok?
> I guess the result length will vary if this is fixed simply.

One idea is that yield the end value instead.

Index: numeric.c
===================================================================
--- numeric.c   (revision 33291)
+++ numeric.c   (working copy)
@@ -1693,7 +1693,10 @@ ruby_float_step(VALUE from, VALUE to, VA
            n = floor(n + err);
            if (!excl || ((long)n)*unit+beg < end) n++;
            for (i=0; i<n; i++) {
-               rb_yield(DBL2NUM(i*unit+beg));
+                double d = i*unit+beg;
+                if (end <= d)
+                    d = end;
+               rb_yield(DBL2NUM(d));
            }
        }
        return TRUE;
-- 
Tanaka Akira