Installing an Inexact Error Handler
Inexact errors occur when a number can’t be represented exactly with the available number of digits, but can be approximated by reducing the number of digits after the decimal. When addition, subtraction, or multiplication result in an inexact error, an RWDecimalInexactErr<T> object is created and passed to an error handler.
By default, an inexact error results in an error message being printed and execution resuming. You can substitute a different action by supplying your own handler. Here is an example:
 
void myInexactHandler(const RWDecimalInexactErr<RWMP2Int>& errobj)
{cerr << “The error message was ‘” << errobj.msg();
cerr << endl;
cerr << “The operands were “ << errobj.leftOperand();
cerr << “ and “ << errobj.rightOperand() << endl;
cerr << “Ignoring loss of precision and continuing”;
cerr << endl;
}
 
yourFunction()
{RWDecimal<RWMP2Int>::setInexactHandler(myInexactHandler);
.
.
.
}