Installing an Overflow Error Handler

An overflow error occurs when a number cannot be represented with the available number of digits. For example 10^30 cannot be represented in the RWDecimal<RWMP3Int> class as it has too many digits. When an operation results in an overflow error, an RWDecimalOverflowErr<T> object is created and passed to an error handler.

The default overflow handler will print an error message and throw the error object as an exception.

 

void myOverflowHandler(const RWDecimalOverflowErr<RWMP2Int>& x)

{. . Error handling code . .

}

 

yourFunction()

{RWDecimal<RWMP2Int>::setOverflowHandler(myOverflowHandler)

.

.

.