From: Robert Ramey (ramey_at_[hidden])
Date: 2019-09-20 14:18:19
On 9/19/19 3:49 AM, blacksmith--- via Boost wrote:
> when using boost multiprecision  to execute even simple math
> operations like addition x = x+1 or x-1 it seems on mathematical error
> it might throw either std::range_error or std::overflow_error or
> std::underflow_error .
> Sadly it seems that it's not the case that overflow and underflow are
> child classes of range_error.
> So, in more complex math expression to detect any math error you must
> write catch(....) for all 3 of them (because just catching common
> std::runtime_error would be too broad and might hide some unrelated error).
> Is there some better way for this?
> Perhaps boost should introduce a common type for math error and throw
> own under/over/range errors that inherit from std's one (for
> compatibility) and also inherit from boost::math_range_error to allow
> catch (boost::math_range_error) // either over/under flow or other math
>  for example using type like:
> boost::multiprecision::number< boost::multiprecision::cpp_int_backend<
> 64-1, 64-1, boost::multiprecision::signed_magnitude,
> boost::multiprecision::checked, void> >
take a look at safe numerics.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk