Sometimes the simplest problems are harder than they first seem. A client once specified a requirement to me: we'll give you the VAT-inclusive (20%) price; you need to generate invoices showing the net and VAT amounts. Sounds easy, right? net = round(tot*5/6) vat = round(tot/6)
It wouldn't fix the problem I described, but an opaque Int type (or value class) with fixed precision, either set to 2 for that type, or encoded in some bits on the left, would he a good way to describe monetary values and avoid floating-point issues.
-
-
http://javax.money .MonetaryAmount or plain old BigDecimal
- End of conversation
New conversation -
-
-
Yes, I saw that from the other responses you've got
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.