I'm looking to have a java class that will hold a decimal value with an arbitrary pre-set precision. The class BigDecimal
looks to be a good candidate as a starting point, but I want to able to limit the size of the decimal to whatever an end user decides. Literally speaking, the end user would specify a range in base 10 and I would allocate enough bytes to represent any number in that range.
I was thinking of having a class that extends BigDecimal
. In this class I would add the functions necessary to mimic a decimal within a pre-set range.
My questions to the community are:
Are there any libraries that already do this?
Would extending BigDecimal
be a reasonable thing to do?