[Seaside] Money ScaledDecimal is it really *appropriate* ?

Valdas Bucinskas valdas.bucinskas at ipsistemos.lt
Thu Feb 2 15:19:38 CET 2006


Hi,

I guess this is how ScaleDecimal prints itself. See printOn: in ScaleDecimal
>> instance.
BTW, if u comment last 2 lines in  that method, you get the desired effect.

Best regards,
Valdas Bucinskas

-----Original Message-----
From: seaside-bounces at lists.squeakfoundation.org
[mailto:seaside-bounces at lists.squeakfoundation.org]On Behalf Of Dmitry
Dorofeev
Sent: Thursday, February 02, 2006 4:14 PM
To: The Squeak Enterprise Aubergines Server - general discussion.
Subject: [Seaside] Money ScaledDecimal is it really *appropriate* ?


Hi,

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....

Thanks.

David T. Lewis wrote:
> in Wed, Feb 01, 2006 at 02:51:42PM +0300, Dmitry Dorofeev wrote:
>
>>Thanks,
>>
>>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'
>
> Dave
>
> _______________________________________________
> Seaside mailing list
> Seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
Seaside mailing list
Seaside at lists.squeakfoundation.org
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



More information about the Seaside mailing list