You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Lukas Bradley <lu...@somnia.com> on 2005/03/17 22:41:26 UTC
Money Class?
I'm running (back) into the age old question of representing monetary
values in Java. Should I use a float and risk floating point errors,
should I use int and hold cents (or pieces of the currency) or should I
create a Money Class to handle both of these problems but create bulkier
code?
Has Commons approached this? I don't need a fully I18N solution, I just
need something that will allow for addition, subtraction, and
calculation of percentages.
Any help or advice appreciated.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: Money Class?
Posted by Steve Farmer <fe...@steve-farmer.com>.
> Should I use a float and risk floating point errors...
In my experience floating point errors are not a "risk", they are a
"certainty".
> ... should I create a Money Class to handle both of these problems but
> create bulkier code?
I've never had an occasion to try it, but I've always thought that
java.math.BigDecimal would be good choice for representing money.
Hope this helps,
Steve Farmer
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org