[ANN] FixedDecimals

Jason Johnson jason.johnson.081 at gmail.com
Sat Sep 1 10:54:01 UTC 2007


nice.

On 8/31/07, Chris Cunningham <cunningham.cb at gmail.com> wrote:
> Hi.
>
> I've just release a package FixedDecimal on SqueakSource.
>
> A FixedDecimal is similar to a ScaledDecimal, but different in certain
> select ways.  It's primary purpose was to be able to represent precise
> decimals for such things as representing money - where ScaledDecimals leave
> something to be desired.  For instance, with ScaledDecimals, you get:
> (33.333s withScale:2) + (33.333s withScale:2)   print it yields 66.67s
> but with FixedDecimals, you would get:
> (33.333 asFixedDecimal: 2) + (33.333 asFixedDecimal: 2)    print it yields
> 66.66.
> So, FixedDecimals round the numbers to the exact scale you specify -
> converting a float to a FixedDecimal and back will not necessarily return
> the starting number, unlike ScaledDecimals.
>
> Most simple arithmetic is defined for FixedDecimals, but not all methods
> that probably should be (it's getting late and I'm going away for the
> weekend - thought I'd publish what I have).
>
> Thanks,
> Chris
>
>
>
>



More information about the Squeak-dev mailing list