Inexact Conditions
Division will use as many digits as necessary for an exact result or all available digits if the exact result requires more digits than are available. For this reason, using the result of a division in a subsequent operation can easily result in a loss of precision exception. This can be avoided by rounding the result to a smaller number of digits using the round function.
Consider the example:
(RWDecimal<RWMP2Int>(1) / RWDecimal<RWMP2Int>(3)) *
RWDecimal<RWMP2Int>(3)
which produces the result
0.999999999999999999 //18 digits = RWDecimal<T>::maxDigits()
Using this value in calculations will likely result in a number with too many digits and a resulting inexact error. The round function can be used to reduce the number of digits after the decimal place:
RWDecimal<RWMP2Int> a = round(result,2);
The pow operation should be used with particular caution since the call,
pow(x, p) // raise x to the integer exponent p
where x is an n-digit number, will produce a result that is up to n* p digits long. If the result has too many digits, it will cause an overflow or precision error.