[Seaside] Money ScaledDecimal is it really *appropriate* ?
dima-sender-3c337a at yasp.com
Thu Feb 2 15:13:50 CET 2006
Assuming I have prices with 2 digits after dot I want to calculate VAT
with 4 digits precision. VAT May be shown still rounded to 2 digits,
but some clients want to see even 4 digits after dot !!! With high
turn over made from small sells it is some real money due to rounding errors :-)
I made some tests and found a funny example:
a := ScaledDecimal newFromNumber: 6.18 scale: 4.
b := ScaledDecimal newFromNumber: 5 scale: 4.
a / b 1.2359s4
a / b printShowingDecimalPlaces: 4 '1.2360'
6.18 / 5.0 1.236
why a / b shows 2.2359s4 ?
but (a / b printShowingDecimalPlaces: 4) shows correct answer
It makes me nervious....
David T. Lewis wrote:
> in Wed, Feb 01, 2006 at 02:51:42PM +0300, Dmitry Dorofeev wrote:
>>this one looks practical.
>>I am sad there is no Money in Squeak though...
> Don't be sad, there is ScaledDecimal in Squeak :)
> Float is *not* appropriate for financial calculations, but
> ScaledDecimal should be OK. And #printShowingDecimalPlaces: will
> work with ScaledDecimal also:
> 123.3453 asScaledDecimal printShowingDecimalPlaces: 2. ==> '123.35'
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
More information about the Seaside