<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Even if <a href="http://bugs.squeak.org/view.php?id=6455">http://bugs.squeak.org/view.php?id=6455</a> example does not fit well with ScaledDecimal/Fraction, that does not make Float expectations more valid.<br></div><div>See #testIndexOfBug6455</div><div><br></div><div>   ((0 to: Float pi by: Float pi / 100) indexOf: Float pi * (3/100))</div><div><br></div><div>I corrected indexOf:startingAt: myself (because fuzziness wasn't correctly implemented), then Levente provided a better implementation.</div><div>But that does not mean that we endorse the feature!</div><div><br></div><div>This kind of expectation is void because of nature of Float.</div><div>See this, the last element in that example is not even Float pi:<br></div><div><br>    (0 to: Float pi by: Float pi / 100) last = 3.1101767270538954.</div><div><br></div><div>We could instead write something like:</div><div><br></div><div>    anglesInDegrees := 0 to: 180 by: 180/100.<br><div>    fractionsOfPi := 0 to: 1 by: 1/100.</div><div><br></div><div>and have our programs behave well better!<br></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le dim. 10 févr. 2019 à 15:27, Nicolas Cellier <<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi,</div><div>does anyone really need a fuzzy Interval indexOf:startingAt: ?</div><div>Right now, we have this:</div><div><div><br></div><div>    ((0.1 to: 0.9 by: 0.1) indexOf: 0.3) = 3.</div></div><div>    ((0.1 to: 0.9 by: 0.1) includes: 0.3) = true.</div><br><div>While this can sound nice, I don't think it is.</div><div>No other collection behaves like that.<br></div><div><br><div>    ((0.1 to: 0.9 by: 0.1) asArray includes: 0.3) = false.<br><div>    ((0.1 to: 0.9 by: 0.1) asSet includes: 0.3) = false.</div></div><div><br></div></div><div>Even Interval itself does not behave consitently:</div><div><br>    ((0.1 to: 0.9 by: 0.1) lastIndexOf: 0.3) = 0.<br></div><div>    ((0.1 to: 0.9 by: 0.1) occurrencesOf: 0.3) = 0.<br>    ((0.1 to: 0.9 by: 0.1) copyWithout: 0.3) = #(0.1 0.2 0.30000000000000004 0.4 0.5 0.6 0.7000000000000001 0.8 0.9).</div><div><br></div><div>We have ScaledDecimal and Fraction which are less surprising, so IMO we should better use them when we really want to play with equality rather than trying to cheat with Float equality.<br></div><div><br></div></div></div></div></div></div>
</blockquote></div>