4 ms·
Not all decimal numbers have finite binary representations. 0.3, for example, is 0.010011 with a repeating block of 0011. For some business applications, you kn
by arn3n 1y ago
Not all decimal numbers have finite binary representations. 0.3, for example, is 0.010011 with a repeating block of 0011. For some business applications, you know you're being given a base 10 decimal of finite (but possibly very large) length.
- eru 1y agoYou can use an arbitrary length integer to store the number of cents? (Or whatever your smallest unit is.) Many languages also have libraries (or standard libraries) for supporting arbitrary length and precision rational numbers.
- viraptor 1y agoDecimals are always represented in a way that preserves the exact value. That doesn't mean internally it needs to be stored in base10. There's lots of ways to achieve that.