[ANN] FixedDecimals

Chris Cunningham cunningham.cb at gmail.com
Fri Aug 31 03:45:44 UTC 2007


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20070830/136bf0e2/attachment.htm


More information about the Squeak-dev mailing list