Martin Fowler in his "Patterns of Enterprise Application Architecture" talks
about a money class and provides a sound implementation of same.
  http://www.martinfowler.com/ap2/quantity.html



-----Original Message-----
From: Dirk Verbeeck [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 18, 2005 2:14 AM
To: Jakarta Commons Users List
Subject: Re: Money Class?

Scale depends on the currency. For example Euro is displayed with 2 decimals
but internal calculations should be done with 4 decimals.

If you are doing a lot of divisions/multiplications then you better don't
limit the intermediate results or the rounding errors will kill the
correctness of the result.

I also recommend creating your own Money Class with a bigdecimal inside.
Then you can add method to read/write the value with the correct number of
decimal digits.

-- Dirk

Lukas Bradley wrote:
> 
>>    I always use BigDecimal for money, and convert to required formats 
>> when viewing. Otherwise, if you need to deal with other currencies, 
>> you might run into trouble.
> 
> 
> Do you limit (scale) your BigDecimal to 2 places?  If so, which 
> constructor do you use?
> 
> Thanks for the reply.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to