Representing Monetary values in Java.
Using float to represent a monetary value is a bad idea because the floating point number is not the true number but the closest approximation. So you will get rounding errors this way. BigDecimal is what you should use for monetary calculations, all very well explained here.
There is also a currency class which can be investigated further too.

0 Comments:
Post a Comment
<< Home