top | item 44059581

(no title)

arn3n | 9 months 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.

discuss

order

eru|9 months ago

You 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|9 months ago

Decimals 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.