4 ms·
The noob-expert meme is really apropos here, as floating-point is really the option to go for if you know nothing about it or you know a lot about it. The "pro
by jcranmer 1y ago
The noob-expert meme is really apropos here, as floating-point is really the option to go for if you know nothing about it or you know a lot about it.
The "problem" with floating-point is that you have to deal with rounding. But in financial contracts, you have to deal with rounding modes. Fixed-point (aka integers) gives you one rounding mode, and that rounding mode is wrong.
- PaulKeeble 1y agoWith ints/longs they usually use something that alternates the rounding so that it spreads, but that alternation can be done on a system wide basis, on a machine basis or in an individual account. For floats what they tend to do is carry around the estimated error when they are doing a lot of calculations and then adjust for the error at the end to bring the value back. Both of them are trying to deal with the inherent issues with the representation being biased and ill suited for money in practice. But oddly this is never pulled together into a Money type because it really depends what you are doing at the time, sometimes you just round and move on and sometimes the error is expected to impact the result because you are dealing with millions/billions with calculations on 10/100s so its going to matter. But reality is the books are basically off by pennies to pounds every day because of these representations and its part of the reason no one worries about being off a little bit because the various systems do this differently.