Hello,

2011/9/17 Tanaka Akira <akr / fsij.org>:
> But in the following script, which changes "a...b" to "a..b" from the abo=
ve
> script, the result length doesn't vary.
>
> % ./ruby -e '
> h =3D Hash.new(0)
> 1000.times {
> =A0a =3D rand
> =A0b =3D a+rand*10000
> =A0s =3D (b - a) / 10
> =A0l =3D (a..b).step(s).to_a.length
> =A0h[l] +=3D 1
> }
> p h
> '
> {11=3D>1000}
>
> This is because we tried to consider float errors
> in Numeric#step for Ruby 1.8. =A0[ruby-dev:20163]


Maybe this "consideration" causes the following behavior:

  p (1.0..12.7).step(1.3).all? {|n| n <=3D 12.7 }  #=3D> false
  p (1.0..12.7).step(1.3).to_a
    #=3D> [1.0, 2.3, 3.6, 4.9, 6.2, 7.5, 8.8, 10.1, 11.4, 12.70000000000000=
1]

Is this ok?
I guess the result length will vary if this is fixed simply.

--=20
Yusuke Endoh <mame / tsg.ne.jp>