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)
-
-
Implement some kind of double booking type, where money can never disappear. I.e. the sum of the values is preserved across all operations?
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
.... all amounts in bitcoin, no rounding. Done!
-
I actually really like the idea of arbitrary-precision money values, independent of bitcoin.
- Show replies
New conversation -
-
-
This Tweet is unavailable.
-
A division and a subtraction would avoid both rounding errors going the same direction and summing to a lost penny.
End of conversation
-
-
-
Actually have faced it in many projects, my workaround define a rounding context to freeze max permissible valid digits in double. e.g. in current work it is 4 decimal with roundup beyond 4. We can also encapsulate it into a class(Type).
-
Also I work in java, have been meaning to develop a Money lib to handle this. I would ideally want a fractional denomination separator, like it might have interface Money and an Implementation like dollar which can represent 1 $ and 56cents without float.
End of conversation
New conversation -
-
-
an accountant I worked with recommended adding a "fudge factor" column to ledgers...
-
Yes, this sounds like an accountants' solution. And that's not meant to sound entirely dismissive: a few pennies lost in accounting doesn't indicate the same sort of problem or solution as an off-by-one error in software engineering.
- Show replies
New conversation -
-
-
I do not get it... Have you used `double` for monetary calculation? But that would not be subtle...
-
Certain whole numbers can't ever be the result of adding 20% to another whole number. If VAT were 100% instead of 20%, you couldn't have a VAT-inclusive price be odd, for example.
- Show replies
New conversation -
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.