Julius Davies wrote:
Why even bother with the "long" version?  I think Money should use
BigDecimal (or BigInteger... whatever) under the hood exclusively.

BigDecimal/BigInteger already have special optimizations for when they
can fit themselves in a long.

(I would more lean towards BigInteger under the hood, and using it to
represent 4 decimal points.)

The difference represents different use cases.

Money allows you to represent $19.95, $0.01, $10,000,000,000,000.00 and so on. The key point is that it is constrained to have two decimal places (or more strictly, the correct number of dp for the currency).

BigMoney (TBD) would allow you to have any value to any size and precision.

Your proposal to always use 4dp would be of no use to a business that needs 5dp or more. (I should also note that performance isn't a critical factor in choosing a long, it just makes more sense for that use case)

The difference is driven by my take on use cases that many businesses would be happy with a simple class and never to have to think about fractions. Whereas others (typically bigger) will have strict, and differeing, rules on what is valid.

Another use case would be storing values using Money, manipulate and calculate using BigMoney and then convert back to Money again for storage.

Stephen

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to