4 ms·
If money wasn't so darn sacrosanct that you absolutely cannot destroy or create even a fraction of a cent... the solution would be to just use floats. I know i
by captainmuon 5y ago
If money wasn't so darn sacrosanct that you absolutely cannot destroy or create even a fraction of a cent... the solution would be to just use floats.
I know it's a big no-no, but I find it odd that we can live with limited precision in scientific computations (even have to), but can't when it comes to money.
- deleted 5y ago[deleted]
- benmller313 5y agoIsn't the real solution just to use a bigger int?
- acdha 5y agoYes, but consider how much volume there is in the stock market - doubling to a 64-bit integer would increase RAM and network volume, and there are plenty of downstream consumers who’d need to test this. None of that is intractable but there’s literally one company affected - the next highest share price is two orders of magnitude lower - so there must be a strong temptation to see what Buffett would want to do a split.
- Nasrudith 5y agoTechnically they can also use variable length integers or even "BigIntegers" but they process slower.
- acdha 5y agoYes - I said 64-bit because that’s a natural size now and for high volume like this it seems likely that they’d prefer a fixed size to savings which make decode and recovery logic harder and less cache line efficient.
- jfk13 5y ago> the next highest share price is two orders of magnitude lower Two orders of magnitude isn't really very much headroom.
- compiler-guy 5y agoIn this domain it is quite a bit of headroom. Normal companies just avoid the problem by splitting before they get even within two orders of magnitude. So if this next-closest share price got closer to the limit, it would almost certainly split long before it became within one order of magnitude of the limit. BH is just a different duck that way.
- andylynch 5y agoNormally issuers would just split the stock. When investors' systems break because your quote is 100x anyone else's you're just making everyone's job harder.
- andylynch 5y agoIt's slightly mystifying they haven't done one already (and yes I know he wants people to buy and hold). This share is very... special in causing these problems and I'm actually surprised NYSE didn't make them do it some time ago.
- Nasrudith 5y agoYou cannot live with it in any system where agency can be taken because of how exploitable it is. If you set up a genetic algorithm in a life simulation and foolishly set it to use floating points "nature" will select for utilizing free energy as a matter of course. HFT + floating point = economy crashed by duping inflation without real item duping
- bidirectional 5y agoHFT programs absolutely use floating point, you don't have time to waste using rationals/fixed point/whatever. I've no idea where this misapprehension has come from, in my experience the more complicated the work you do in finance, the more you balk at the idea of not using floating point.
- pgwhalen 5y agoAs some sibling comments suggest, not all finance is created the same. Trading systems often use floating point, but banking/accounting systems used fixed point. The key is whether your system needs to tally up your monies into a known quantity and ensure it is all accounted for. If you summed up the transactions across a number of customer accounts at a bank for instance, it's critical that they all net out.
- bidirectional 5y agoFloats are used in finance for many applications. Most of the front office applications I've worked on use floats for money, because it's like science: the model is already off by more than floating point error. The whole "NEVER use floats for money" thing is cargo culting. In this situation though I don't see why floats would be any better a solution than just using 64-bit integers.
- jschwartzi 5y agoIt's more accurate to say "never use floats for accounting." You should be able to state with 100% certainty how much money you owe no matter how much money you owe.
- klyrs 5y agoNot 100%. There's gotta be a precision cutoff somewhere between $1 and the inverse of Avogadro's number.
- jschwartzi 5y agoI'll cede this point. If you're accounting for the quantity of pennies down to the precision of individual penny atoms then your accounting must be accurate to within the quantity of penny atoms that are rubbed off the penny during normal handling during the transaction.
- montecarl 5y agoIn scientific computations, it is often sufficient that the final answer is correct to a few significant figures. There are several reasons for this. One is that the model uncertainty is typically quite large (unless you are dealing with particle physics). Another is measurement uncertainty. Except for some unique scenarios measurements aren't going to have more than a few significant figures as well. So there isn't a big difference between 3.14 and 3.14159 and pi to 100 decimals. I'm sure one can think of plenty of counter examples, but I'll give an example where floating point numbers are used heavily and you don't typically don't care about minor rounding issues. Computational chemistry can be used to predict the geometry of molecules. The model used to make this prediction has to describe the interactions between the atoms, which is computationally expensive (solving Schrodinger's equation). So often times the molecule is only modeled in a vacuum and not as a liquid (where there would be many other molecules included). All of these add up that even if there was no IEEE-754 floating point error, the answer would still maybe only be right to +/- 10%. So science is quite different from finance, where the main goal is to converse a certain quantity. Money shouldn't be created or lost though rounding errors.
- compiler-guy 5y agoRounding error in finances is a major plot point in the introduction SuperMan III. https://www.youtube.com/watch?v=N7JBXGkBoFc https://www.youtube.com/watch?v=N7JBXGkBoFc Sure, it's humorous and a little bit silly, but the issue is a real one, and this is a funny way to familiarize yourself with the tricks that can be played.