mirror of
https://github.com/boostorg/math.git
synced 2025-05-11 21:33:52 +00:00
BREAKING CHANGE: Correct definition of user_rounding_error, (#836)
* BREAKING CHANGE: Correct definition of user_rounding_error, To return correct type. Likewise fix up a few other rounding error inconsistencies. Fixes https://github.com/boostorg/math/issues/834. * Remove redundant error handler.
This commit is contained in:
parent
ea9c3a27e9
commit
ddf0143a8c
@ -107,8 +107,8 @@ must be provided by the user:
|
||||
template <class T>
|
||||
T user_rounding_error(const char* function, const char* message, const T& val);
|
||||
|
||||
template <class T>
|
||||
T user_evaluation_error(const char* function, const char* message, const T& val);
|
||||
template <class T, class TargetType>
|
||||
TargetType user_rounding_error(const char* function, const char* message, const T& val, const TargetType& t);
|
||||
|
||||
template <class T>
|
||||
T user_indeterminate_result_error(const char* function, const char* message, const T& val);
|
||||
|
@ -39,7 +39,7 @@ boost/math/policies/error_handling.hpp like this:
|
||||
template <class T>
|
||||
T user_evaluation_error(const char* function, const char* message, const T& val);
|
||||
template <class T, class TargetType>
|
||||
T user_rounding_error(const char* function, const char* message, const T& val, const TargetType& t);
|
||||
TargetType user_rounding_error(const char* function, const char* message, const T& val, const TargetType& t);
|
||||
template <class T>
|
||||
T user_indeterminate_result_error(const char* function, const char* message, const T& val);
|
||||
|
||||
|
@ -74,7 +74,7 @@ T user_denorm_error(const char* function, const char* message, const T& val);
|
||||
template <class T>
|
||||
T user_evaluation_error(const char* function, const char* message, const T& val);
|
||||
template <class T, class TargetType>
|
||||
T user_rounding_error(const char* function, const char* message, const T& val, const TargetType& t);
|
||||
TargetType user_rounding_error(const char* function, const char* message, const T& val, const TargetType& t);
|
||||
template <class T>
|
||||
T user_indeterminate_result_error(const char* function, const char* message, const T& val);
|
||||
|
||||
@ -561,7 +561,7 @@ inline constexpr TargetType raise_rounding_error(
|
||||
{
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be ignored so here we go anyway:
|
||||
static_assert(std::numeric_limits<TargetType>::is_specialized, "The target type must be specialized.");
|
||||
static_assert(std::numeric_limits<TargetType>::is_specialized, "The target type must have std::numeric_limits specialized.");
|
||||
return val > 0 ? (std::numeric_limits<TargetType>::max)() : (std::numeric_limits<TargetType>::is_integer ? (std::numeric_limits<TargetType>::min)() : -(std::numeric_limits<TargetType>::max)());
|
||||
}
|
||||
|
||||
@ -576,24 +576,9 @@ inline TargetType raise_rounding_error(
|
||||
errno = ERANGE;
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be silent so here we go anyway:
|
||||
static_assert(std::numeric_limits<TargetType>::is_specialized, "The target type must be specialized.");
|
||||
static_assert(std::numeric_limits<TargetType>::is_specialized, "The target type must have std::numeric_limits specialized.");
|
||||
return val > 0 ? (std::numeric_limits<TargetType>::max)() : (std::numeric_limits<TargetType>::is_integer ? (std::numeric_limits<TargetType>::min)() : -(std::numeric_limits<TargetType>::max)());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T raise_rounding_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const T& val,
|
||||
const T&,
|
||||
const ::boost::math::policies::rounding_error< ::boost::math::policies::errno_on_error>&) BOOST_MATH_NOEXCEPT(T)
|
||||
{
|
||||
errno = ERANGE;
|
||||
// This may or may not do the right thing, but the user asked for the error
|
||||
// to be silent so here we go anyway:
|
||||
return val > 0 ? boost::math::tools::max_value<T>() : -boost::math::tools::max_value<T>();
|
||||
}
|
||||
|
||||
template <class T, class TargetType>
|
||||
inline TargetType raise_rounding_error(
|
||||
const char* function,
|
||||
|
Loading…
x
Reference in New Issue
Block a user