5 ms·
That's got nothing to do with perf tho.
by amanda99 2y ago
That's got nothing to do with perf tho.
- Maxatar 2y agoNothing to do with perf is a strong claim. If you genuinely don't care about performance you can use an arbitrary-precision rational number representation. But performance often matters, so you trade off precision for performance. I think people are wrong to dismiss floating point numbers in favor of fixed point arithmetic, and I've seen plenty of fixed point arithmetic that has failed spectacularly because people think if you use it, it magically solves all your problems... Whatever approach you take other than going all in with arbitrary precision fractions, you will need to have a good fundamental understanding of your representation and its trade-offs. For me personally I use floating point binary and adjust the decimal point so I can exactly represent any value to 6 decimal places. It's a good trade-off between performance, flexibility, and precision. It's also what the main Bitcoin implementation uses.
- fluoridation 2y agoHuh? Bitcoin uses integers. The maximum supply of BTC in satoshis fits in 64 bits. JS implementations that need to handle BTC amounts use doubles, but only by necessity, since JS doesn't have an integer type. They still use the units to represent satoshis, which works because the maximum supply also fits in 53 bits, so effectively they're also using integers. Anyone who uses binary floating point operations on monetary values doesn't know what they're doing and is asking for trouble.
- wbl 2y agoSo if I want to price a barrier in Bermudan rainbow via Monte Carlo I should take the speed hit for a few oddball double rounding problems that are pennies?
- fluoridation 2y agoI mean, you do you. People generally don't complain if you're a couple hundred nanoseconds (if that) late. They do complain if your accounts don't add up by a single penny.
- wbl 2y agoThe quoting of something exotic like this is not well defined to the penny. It's transactions where people really care about pennies.