commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dirk Verbeeck <dirk.verbe...@pandora.be>
Subject Re: Money Class?
Date Fri, 18 Mar 2005 07:14:04 GMT
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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message