I guess the &quot;general rule with floats&quot; is &quot;Never use = or equivalence to compare them. Only use &gt; or &lt; or check within a tolerance&quot;.<br><br><div>- Darius</div><br><div class="gmail_quote">On Mon, May 7, 2012 at 8:16 AM, Chris Muller <span dir="ltr">&lt;<a href="mailto:ma.chris.m@gmail.com" target="_blank">ma.chris.m@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Ok, thanks Darius (and Levente).  At first I thought we had a<br>
regression but it looks like we don&#39;t..   :)<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On Mon, May 7, 2012 at 12:51 AM, Darius Clarke &lt;<a href="mailto:socinian@gmail.com">socinian@gmail.com</a>&gt; wrote:<br>
&gt; I don&#39;t believe roundTo: is the method you&#39;re looking for.<br>
&gt; I&#39;ve been confused by this before.<br>
&gt;<br>
&gt; roundTo: quantum<br>
&gt; &quot;Answer the nearest number that is a multiple of quantum.&quot;<br>
&gt;<br>
&gt; ^(self / quantum) rounded * quantum<br>
&gt;<br>
&gt; Maybe try this:<br>
&gt;<br>
&gt; roundedToFloat: quantum<br>
&gt; &quot;Round to decimal places.&quot;<br>
&gt; | aReciprocal |<br>
&gt; aReciprocal := quantum reciprocal rounded.<br>
&gt;<br>
&gt; ^(self * aReciprocal) rounded / aReciprocal asFloat<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Sun, May 6, 2012 at 9:20 PM, Levente Uzonyi &lt;<a href="mailto:leves@elte.hu">leves@elte.hu</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; On Sun, 6 May 2012, Chris Muller wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt; ( 0.9580000000000001 roundTo: 0.0001) = 0.9580   &quot;false&quot;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Still didn&#39;t look at the code, but 0.0001 is also a Float and it doesn&#39;t<br>
&gt;&gt; have an exact representation in base 2. The following works as expected:<br>
&gt;&gt; (0.9580000000000001 roundTo: 0.0001s4) &quot;0.9580s4&quot;<br>
&gt;&gt; (0.9580000000000001 roundTo: 1/10000) &quot;(479/500)&quot;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Levente<br>
&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Sun, May 6, 2012 at 8:55 PM, Levente Uzonyi &lt;<a href="mailto:leves@elte.hu">leves@elte.hu</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; On Sun, 6 May 2012, Chris Muller wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; With the latest trunk updates, I&#39;m having trouble rounding to my<br>
&gt;&gt;&gt;&gt;&gt; desired precision:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;    0.9580000000000001 roundTo: 0.0001    &quot; 0.9580000000000001&quot;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; In Squeak 4.3 I get what I expect:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;    0.9580000000000001 roundTo: 0.0001   &quot; 0.958&quot;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I&#39;m pretty sure it&#39;s just a difference in printing. 0.958 is unlikely to<br>
&gt;&gt;&gt;&gt; have an exact base 2 representation.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Levente<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
</div></div></blockquote></div><br>