From: "NARUSE, Yui" Date: 2011-09-17T18:27:12+09:00 Subject: [ruby-core:39607] Re: [Ruby 1.9 - Bug #4576] Range#step miss the last value, if end-exclusive and has float number (2011/09/17 16:14), Yusuke ENDOH wrote: > Hello, > > 2011/9/17 NARUSE, Yui : >> 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. > > > I have no understanding of the error, but your patch does not > work in this case: > > e = 1.0 + 1E-12 > p (1.0 ... e).step(1E-16).all? {|n| n < e } #=> false > p (1.0 ... e).step(1E-16).to_a.last == e #=> true Your case is not the target of my patch. -- NARUSE, Yui