- Q: Why would I use JQuantity instead of BigInteger or BigDecimal?
- A: BigInteger is limited to expressing integers and BigDecimal
can only express BigIntegers divided by powers of ten. If you want a mathematical
framework which frees you from these restrictions, then you need JQuantity.
- Q: What do you mean by numbers which are precise or
have known precision?
- A: One of the major limitations of computing systems
and calculators is that they do not keep track of precision for the user.
For example, suppose we carry out a series of trigonometrical calculations
using the value 355/113 for pi. How will that affect all our results? Or
what will happen if we divide 10 by 3 and then multiply by 3. Do we get 10
back? Or do we get 9.999999999? If we get the latter result, how do we
know that it really ought to be showing the value 10? We don't. The JQuantity
framework is designed to address all of these issues using a method called
"lazy evaluation". When we start with a number 10 in the jquantity package
and then divide it by 3, we get a ratio of 10/3 rather than some number such
as 3.3333333. When we multiply that result by 3, we get back 10: neither
more nor less. Or if we start with the value of pi and take its cosine, we
will get exactly -1, neither more nor less.