Why is the scale
field of a BigDecimal
not a BigInteger
? I assume currently it makes maybe no sense because calculations with that many decimal places are likely never performed, but wouldn't it make sense for the future to rather use a BigInteger
?
The scale of a BigDecimal is the number of digits it stores to the right of the decimal point. It is an amount of memory in that those digits are actually stored, and it is an amount of work in that most operations on a BigDecimal will have to do work on all of those digits.
It is never going to be a good idea to use a BigDecimal that takes an amount of memory or work that doesn't fit into an int, so an int is used for scale. That's the same reason int is used for string lengths and collection sizes, etc.
In the rare cases that a reasonable amount of memory or work doesn't fit into an int, it certainly fits into a long. Longs are used for file sizes and position, for example. A BigInteger is never required.