<div class="gmail_quote">On Wed, Feb 18, 2009 at 12:21 PM, Michael van der Gulik <span dir="ltr">&lt;<a href="mailto:mikevdg@gmail.com">mikevdg@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br>Could you give me an example? It isn&#39;t immediately intuitive to me what incorrect results might occur. Rounding errors maybe?<br>
</blockquote>
<div>Well, I had to go back and figure out what they were ( I don&#39;t have the exact examples that caused this issue in the first place).&nbsp; However, if you have an intermediate calculation that results in a fraction more precise than what you need, and you make a scaledDecimal out of it, you can get weird results.&nbsp; The example:</div>

<div>&nbsp;</div>
<div>33.33 + 33.33 + 33.33 + 33.33 = 133.32 &quot;in real math&quot;</div>
<div>&nbsp;</div>
<div>x := 33.333s2.&nbsp;&nbsp; &quot;This prints as 33.33s2, giving the illusion that you have it exactly as this amount&quot;</div>
<div>x + x + x + x = 133.33s2&nbsp; &quot;Not accurate, depending on exactly what you are trying to measure&quot;</div>
<div>&nbsp;</div>
<div>y := 33.333 asFixedDecimal: 2.&nbsp; &quot;This prints as 33.33&quot;</div>
<div>y + y + y + y = 133.32&nbsp; &quot;that is, the fixed decimal of scale 2 truely truncated the value, and the result is correct, depending on what you are measuring&quot;</div>
<div>&nbsp;</div>
<div>So, if you need to keep the original precision and you are just want to present it at a lower precision, ScaledDecimal is exactly what you want.&nbsp; If, on the other hand, you want the number to be at exactly the precision that you tell it it should be, then FixedDecimal is what you want.</div>

<div>&nbsp;</div>
<div>-Chris</div></div>