Issue #4576 has been updated by Shyouhei Urabe.


Marc-Andre Lafortune wrote:
> On Tue, Sep 13, 2011 at 9:13 AM, Shyouhei Urabe <shyouhei / ruby-lang.org> wrote:
> > No. ??Sorry. ??Ruby is not designed like that. ??Ruby's design is that it embraces the world we live, no matter it is ugly. ??Ruby do not hide its ugliness from your eyes.
> 
> What makes you think this? This is simply not true. Math in Ruby aims to be as platform independent as is reasonable. For example see Matz in [ruby-core:28212].

I'm pretty sure Matz wasn't interested in the current implementation.  He always says what he wants i.e. his statements do not apply to the one we already have.  OTOH I've never said about any future plans about this area.  I'm not against a Ruby in 22nd century to fully comply IEEE floats.  But today, it's really considerably painfully difficult to force an Intel chip to behave under IEEE arithmetic[1].  It's clearer than light that the current ruby don't pay the cost to achieve it.

[1] http://www.shudo.net/publications/java-hpc2000/shudo-Java4HPC-strictfp.pdf
----------------------------------------
Bug #4576: Range#step miss the last value, if end-exclusive and has float number
http://redmine.ruby-lang.org/issues/4576

Author: Joey Zhou
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: 1.9.4
ruby -v: -


=begin
Hi, I find that:

* if: range.exclude_end? == true
* and: any one in [begin_obj, end_obj, step] is a true Float(f.to_i != f)
* and: unless begin_obj + step*int == end_obj
* then: the result will miss the last value.

for example:

 p (1...6.3).step.to_a # => [1.0, 2.0, 3.0, 4.0, 5.0], no 6.0
 p (1.1...6).step.to_a # => [1.1, 2.1, 3.1, 4.1], no 5.1
 p (1...6).step(1.1).to_a # => [1.0, 2.1, 3.2, 4.300000000000001], no 5.4

 p (1.0...6.6).step(1.9).to_a # => [1.0, 2.9], no 4.8
 p (1.0...6.7).step(1.9).to_a # => [1.0, 2.9, 4.8]
 p (1.0...6.8).step(1.9).to_a # => [1.0, 2.9, 4.8], no 6.7

Maybe the #step is ok on integers, but there's something wrong if the range is end-exclusive and contain float numbers.
=end



-- 
http://redmine.ruby-lang.org