[Pharo-project] SIXX problem for ScaledDecimal

Ralph Boland rpboland at gmail.com
Fri May 20 16:57:12 CEST 2011


> From: Chris Cunningham <cunningham.cb at gmail.com>
> Subject: Re: [Pharo-project] SIXX problem for ScaledDecimal
> To: Pharo-project at lists.gforge.inria.fr
> Message-ID: <BANLkTinP7E_oh2Fi2=axmra6JsoXVJYWkg at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1

> For ScaledDecimal, SIXX should definite store it as the underlying
> fraction.  Storing it in the printed fashion does change the value of
> the ScaledDecimal.

> (1/3) asScaledDecimal: 2  gives  0.33s2
> and
> (33/100) asScaledDecimal: 2  gives  0.33s2
> yet
> 0.33s2 ~= ( (1/3) asScaledDecimal: 2 )
> and
> ( (1/3) asScaledDecimal: 2 ) ~= ( (33/100) asScaledDecimal: 2 )

> In other words, the ScaledDecimal is about the precise internal number
> and the scale to display it - which is NOT the scale that it is stored
> as.

> -Chris

I don't agree.  ScaledDecimal would be used where consistency is often
more important than accuracy, e.g. in Financial calculations where being off by
a few pennies doesn't matter but always getting the same answer matters a LOT.
Once a number is converted to a ScaledDecimal computations must always
produce the same result assuming enough digits.  To ensure this asScaledDecimal
must produce a scaled decimal for use in computations and, as such, storing
a fraction internally is unacceptable.


More information about the Pharo-project mailing list