<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Feb 13, 2015 at 4:56 PM, nicolas cellier <span dir="ltr">&lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">...<br>
<br>
If it&#39;s for monetary things like computing interests, then the advice is to<br>
not use Float but ScaledDecimal.<br>
<br>
100 * (1.05s2 raisedTo: 10) roundTo: 0.01s2<br>
-&gt; 162.89s2<br>
<span class=""><font color="#888888"><br>
Nicolas<br>
</font></span><div class=""><div class="h5"><br></div></div></blockquote><div>So, for money, I would suggest not using ScaledDecimal, but rather FixedDecimal.</div><div><br></div><div>ScaledDecimal can do funny things that you would not expect in real money land:</div><div><br></div><div>m := 1/3 asScaledDecimal: 2.</div><div>m  &quot;==&gt; 0.33s2&quot;</div><div>m + m + m &quot;==&gt; 1.00s2&quot;</div><div><br></div><div>You shouldn&#39;t be allowed to add 33 cents together and get a whole dollar (usd, at least)!</div><div><br></div><div>FixedDecimal actually rounds to the specified length (ScaledDecimal keeps the entire precision &#39;behind the curtains&#39;).</div><div><br></div><div><div>m := 1/3 asFixedDecimal: 2.</div><div>m  &quot;==&gt; 0.33&quot;<br></div><div>m + m + m &quot;==&gt;  0.99&quot;</div></div><div><br></div><div><a title="static project url" href="http://www.squeaksource.com/FixedDecimal.html" style="color:rgb(54,0,132);text-decoration:none;font-family:Geneva,Arial,Helvetica,sans-serif;font-size:15.039999961853px;text-align:justify">http://www.squeaksource.com/FixedDecimal.html</a><br></div><div><br></div><div>-cbc</div><div><br></div><div> </div></div></div></div>