4 ms·
Money comes in integers. Any function that works with monetary values needs to eat integers and output integers. This is not pedantry, it's a real-world constr
by thanatropism 9y ago
Money comes in integers. Any function that works with monetary values needs to eat integers and output integers.
This is not pedantry, it's a real-world constraint.
- eropple 9y agoI thought your "real-world constraint" existed too. Then I had to keep track of thousandths of a cent. When you have experienced the "no, a cent is no longer granular enough" problem, the conversion of DECIMAL(7,2) to DECIMAL(9,4) and the attendant code compatibility is something you'll appreciate.
- Roboprog 9y agoThat's what fixed precision types are: integers + a scale factor -- whether it's cents, mils or something else. Javascript does badly need a native fixed precision type beyond "everything is a double" or some web assembly hack. And I like Javascript, but this is a real problem.