2 ms·
Did you know in the US it's essentially against the law to use floating point math on currency? The situation is more complex than I simplified here, however th
by DiabloD3 9y ago
Did you know in the US it's essentially against the law to use floating point math on currency? The situation is more complex than I simplified here, however the complexity is on the order than you'd need a lawyer to explain it to you to really appreciate it.
You can call it a knee-jerk reaction, but the law itself clearly has that bias, and for good reason.
All regulations were paved in blood.
- phpnode 9y agoWhich law covers that?
- _0ffh 9y agoNot just the US, IIRC financial institutions around the world are required to do decimal rounding. OTOH I don't see why you would even use floating point for money. Just scale your integers to the required precision (and make sure you've got enough bits for the kind of amounts you need to be able to handle) and you're good.
- davidcuddeback 9y agoHaving worked in both aerospace (GP's comment) and e-commerce (your comment), I can tell you that these are not the same problem and do not require the same solution. First week on the job in e-commerce, I educated the junior engineers on the problems that can arise when using floating point math with currencies, then prioritized work to remove any floating point math from the code. That doesn't mean I wouldn't use floating point anywhere else. In aerospace in particular, I've used floating-point without issue, so I don't think you're point about currencies has any relevancy to the GP's comment regarding fuel estimation.
- fnord77 9y agofun fact - before 2001, the US stockmarket traded in sixteenths not decimals