4 ms·
How can a protocol dealing with currency invented after year 2000 have limits on the number of decimals or its positionn?
by Nilzor 13y ago
How can a protocol dealing with currency invented after year 2000 have limits on the number of decimals or its positionn?
- nfoz 13y agoI'll hazard a guess: the protocol might not want to allow arbitrarily large transaction messages. Could introduce points of failure / DOS'ing.
- bnr 13y agoI have 1 bitcoin. I send you 2^-32 btc. How much do I have left?
- bunderbunder 13y agoIn a nutshell, because sometimes the point really does not (and should not) float. The main reason for choosing variable-precision numbers for general-purpose computing is that they have a very wide dynamic range that can adjust automatically, which makes them easier to use in more situations. In financial applications, that advantage doesn't really apply; banks don't often encounter situations where customers are worried about a ten thousandth of a cent, and they never encounter situations where it's suddenly OK to only track a transaction with dollar-level precision. Meanwhile there are some risks to using arbitrary-precision math too. If BTC used floats, then that might result in it being vulnerable to attacks that are able to take advantage of rounding errors in floating-point math. If BTC used infinite-precision decimals, then that might result in it being vulnerable to attacks that work by creating ridiculously high-precision numbers that implementations have a hard time dealing with.