First, is FixedDecimal used in the Money package?  I didn't see is
referenced there, so I'm curious where it came from.

There is a definite different between ScaledDecimal and FixedDecimal.
 ScaledDecimal  (unless it's been changed recently) keeps the full
precision of the original number.  FixedDecimal (and Money, from my short
perusal of it), do not - they make sure that the displayed value is exactly
what the internal value is.  As an example, check out the following:

x := ((1/3) asScaledDecimal: 2).
x      ==> 0.33s2
x = (1/3)  ==> true
((33/100) asScaledDecimal: 2) ==> 0.33s2
x = ((33/100) asScaledDecimal: 2) ==> false (!)
x + x  ==> 0.67s2 (!)

In general, the last 2 statements are NOT what you want when dealing with
Money - if you have an amount, it is a definite amount, and not an
approximate amount.  (With the possible exceptions of interim results - but
for those, you probably need strict control over exactly how precise the
interim results are - which isn't readily available in ScaleDecimal).  This
is the main reason I built the FixedDecimal package on SqueakSource.
 There, the above statements show:

x := ((1/3) asFixedDecimal: 2).
x      ==> 0.33
x = (1/3)  ==> true
((33/100) asFixedDecimal: 2) ==> 0.33
x = ((33/100) asFixedDecimal: 2) ==> true
x + x  ==> 0.66

>From my perspecive, ScaledDecimal is great when you want to keep as much
precision as possible, but need to SHOW less precision.  It reminds me of
science, where you have this measurement that is way more precise than you
can really measure, so you 'scale' it back to a precision that is reliable.

-Chris


On Tue, Jun 11, 2013 at 1:21 PM, Mariano Martinez Peck <
[email protected]> wrote:

> I wondered the same. Can someone explain?
>
>
> On Tue, Jun 11, 2013 at 3:17 AM, Denis Kudriashov <[email protected]>wrote:
>
>> What the difference from scaled decimal or fixed decimal?
>>
>> On video I not see any currency concept.
>> In past I used Units package to model money. It is very convinient to
>> calculate currency exchange operations.
>> What the advantage of Money package?
>>
>> Best regards,
>> Denis
>>
>>
>> 2013/6/10 Torsten Bergmann <[email protected]>
>>
>>> Do we have a "money" package for Pharo available?
>>>
>>>
>>> http://www.jarober.com/blog/blogView?showComments=true&title=ST+4U+396%3A+Money+in+VA+Smalltalk&entry=3547452513
>>>
>>>
>>>
>>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>

Reply via email to