For more info, see my other question, here. So anyway, I’m using BigDecimals to represent currency in my application (it deducts a markdown percentage and adds sales tax), but it seems that If I use a BigDecimal for the price, everything needs to be BigDecimals. Is it OK to use a BigDecimal for the markdown percentage field (instead of a float), and also for the PST and GST constants (sales tax, 0.08 & 0.05)? Oh and also, do you think I should store the markdown field in percentage or decimal? Either way, I would have to convert it to the other for display, since I show p / 100 = d. And subtotal means the total cost before tax, right?
Thanks!!
Different industries will have different standards for this. In finance, for example, it’s common to do calculations to 5 or even 8 decimal places even if you’re only display 2 or 3.
BigDecimals are preferred for being completely accurate for multiplication, addition and subtraction (division isn’t normally an issue when it comes to currency amounts).