From: Tanaka Akira Date: 2011-09-17T07:28:14+09:00 Subject: [ruby-core:39593] Re: [Ruby 1.9 - Bug #4576] Range#step miss the last value, if end-exclusive and has float number 2011/9/17 Marc-Andre Lafortune : > > I'd like to thank Vit Ondruch and Ale�� Mare��ek for pointing out this issue, investigating it and providing insight as to how to fix it. > > I am sorry that this problem has not been fixed yet. I completely agree that this is a bug and that Ruby_with_patch >= Ruby_without_patch. I don't think the patch is a appropriate fix for this problem. The test, "n*unit+beg < end", is fragile. n*unit+beg can be different from the true mathematical value because floating point calculation errors, as you know. It can be bigger or smaller than the true value. So the test should be changed to "n*unit+beg - e < end" for a estimated maximum error, e. I beleave the result of "*" and "+" is the nearest representable value of the true mathematical result. So I guess the maximum error is abs(a*DBL_EPSILON) + abs(b*DBL_EPSILON) where a = n*unit and b = a + beg. The estimate may be too small as considering double rounding problem of x86 80bit float issue, though. Note that I am not a expert of floating point calculations. Is there someone can validate the above logic? -- Tanaka Akira