From: "Vít Ondruch" <v.ondruch@...>
Date: 2011-09-13T18:56:52+09:00
Subject: [ruby-core:39508] Re: [Ruby 1.9 - Bug #4576] Range#step miss the last value, if end-exclusive and has float number

--bcaec5395f14797dfb04accfa9c7
Content-Type: text/plain; charset=ISO-8859-1

Can somebody please reopen this issue? Since the test suite fix is
apparently wrong.

Thank you.


Vit


2011/8/30 Vit Ondruch <v.ondruch@tiscali.cz>

>
> Issue #4576 has been updated by Vit Ondruch.
>
> File 0001-Fix-the-ronding-error-causing-wrong-evaluation-of-ra.patch added
>
> Usaku NAKAMURA wrote:
> > =begin
> >  Hello,
> >
> >  In message "[ruby-core:35804] [Ruby 1.9 - Bug #4576] Range#step miss the
> last value, if end-exclusive and has float number"
> >      on Apr.18,2011 12:06:24, <redmine@ruby-lang.org> wrote:
> >  > test_step_ruby_core_35753 seems depend on platform.
> >  > On i686-linux it fails.
> >
> >  Ah, I doubt it. Thank you.
> >
> >
> >  > May i partially revert an testcase of test_step_ruby_core_35753?
> >
> >  No.
> >  I guess that 1.5 stepping doesn't have error.
> >  Please test r31304.
> >
> >
> >  Regards,
> >  --
> >  U.Nakamura <usa@garbagecollect.jp>
> > =end
>
> Can we reopen this issue please? The fix of unit tests was wrong, fixing
> consequences instead of reasons. Moreover, it was not backported to 1.8.7,
> so we hit the issue again when preparing updated package for RHEL 6.2. You
> can find the discussion about the issue at [1] including proposed solution
> [2]. Could you please review and apply the attached patch and also backport
> it to 1.8.7?
>
> [1] https://bugzilla.redhat.com/show_bug.cgi?id=733372
> [2] https://bugzilla.redhat.com/attachment.cgi?id=520552
> ----------------------------------------
> 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: Closed
> Priority: Normal
> Assignee:
> Category:
> Target version:
> 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
>
>

--bcaec5395f14797dfb04accfa9c7
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Can somebody please reopen this issue? Since the test suite fix is apparent=
ly wrong.<br><br>Thank you.<br><br><br>Vit<br><br><br><div class=3D"gmail_q=
uote">2011/8/30 Vit Ondruch <span dir=3D"ltr">&lt;<a href=3D"mailto:v.ondru=
ch@tiscali.cz">v.ondruch@tiscali.cz</a>&gt;</span><br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex;"><br>
Issue #4576 has been updated by Vit Ondruch.<br>
<br>
File 0001-Fix-the-ronding-error-causing-wrong-evaluation-of-ra.patch added<=
br>
<br>
Usaku NAKAMURA wrote:<br>
&gt; =3Dbegin<br>
<div><div></div><div class=3D"h5">&gt; =A0Hello,<br>
&gt;<br>
&gt; =A0In message &quot;[ruby-core:35804] [Ruby 1.9 - Bug #4576] Range#ste=
p miss the last value, if end-exclusive and has float number&quot;<br>
&gt; =A0 =A0 =A0on Apr.18,2011 12:06:24, &lt;<a href=3D"mailto:redmine@ruby=
-lang.org">redmine@ruby-lang.org</a>&gt; wrote:<br>
&gt; =A0&gt; test_step_ruby_core_35753 seems depend on platform.<br>
&gt; =A0&gt; On i686-linux it fails.<br>
&gt;<br>
&gt; =A0Ah, I doubt it. Thank you.<br>
&gt;<br>
&gt;<br>
&gt; =A0&gt; May i partially revert an testcase of test_step_ruby_core_3575=
3?<br>
&gt;<br>
&gt; =A0No.<br>
&gt; =A0I guess that 1.5 stepping doesn&#39;t have error.<br>
&gt; =A0Please test r31304.<br>
&gt;<br>
&gt;<br>
&gt; =A0Regards,<br>
&gt; =A0--<br>
&gt; =A0U.Nakamura &lt;<a href=3D"mailto:usa@garbagecollect.jp">usa@garbage=
collect.jp</a>&gt;<br>
</div></div>&gt; =3Dend<br>
<br>
Can we reopen this issue please? The fix of unit tests was wrong, fixing co=
nsequences instead of reasons. Moreover, it was not backported to 1.8.7, so=
 we hit the issue again when preparing updated package for RHEL 6.2. You ca=
n find the discussion about the issue at [1] including proposed solution [2=
]. Could you please review and apply the attached patch and also backport i=
t to 1.8.7?<br>

<br>
[1] <a href=3D"https://bugzilla.redhat.com/show_bug.cgi?id=3D733372" target=
=3D"_blank">https://bugzilla.redhat.com/show_bug.cgi?id=3D733372</a><br>
[2] <a href=3D"https://bugzilla.redhat.com/attachment.cgi?id=3D520552" targ=
et=3D"_blank">https://bugzilla.redhat.com/attachment.cgi?id=3D520552</a><br=
>
<div class=3D"im">----------------------------------------<br>
Bug #4576: Range#step miss the last value, if end-exclusive and has float n=
umber<br>
<a href=3D"http://redmine.ruby-lang.org/issues/4576" target=3D"_blank">http=
://redmine.ruby-lang.org/issues/4576</a><br>
<br>
Author: Joey Zhou<br>
</div>Status: Closed<br>
<div class=3D"im">Priority: Normal<br>
Assignee:<br>
Category:<br>
Target version:<br>
</div>ruby -v: -<br>
<br>
<br>
=3Dbegin<br>
<div class=3D"im">Hi, I find that:<br>
<br>
* if: range.exclude_end? =3D=3D true<br>
* and: any one in [begin_obj, end_obj, step] is a true Float(f.to_i !=3D f)=
<br>
* and: unless begin_obj + step*int =3D=3D end_obj<br>
* then: the result will miss the last value.<br>
<br>
for example:<br>
<br>
=A0p (1...6.3).step.to_a # =3D&gt; [1.0, 2.0, 3.0, 4.0, 5.0], no 6.0<br>
=A0p (1.1...6).step.to_a # =3D&gt; [1.1, 2.1, 3.1, 4.1], no 5.1<br>
=A0p (1...6).step(1.1).to_a # =3D&gt; [1.0, 2.1, 3.2, 4.300000000000001], n=
o 5.4<br>
<br>
=A0p (1.0...6.6).step(1.9).to_a # =3D&gt; [1.0, 2.9], no 4.8<br>
=A0p (1.0...6.7).step(1.9).to_a # =3D&gt; [1.0, 2.9, 4.8]<br>
=A0p (1.0...6.8).step(1.9).to_a # =3D&gt; [1.0, 2.9, 4.8], no 6.7<br>
<br>
Maybe the #step is ok on integers, but there&#39;s something wrong if the r=
ange is end-exclusive and contain float numbers.<br>
</div>=3Dend<br>
<font color=3D"#888888"><br>
<br>
<br>
--<br>
</font><div><div></div><div class=3D"h5"><a href=3D"http://redmine.ruby-lan=
g.org" target=3D"_blank">http://redmine.ruby-lang.org</a><br>
<br>
</div></div></blockquote></div><br>

--bcaec5395f14797dfb04accfa9c7--