mirror of
https://github.com/boostorg/math.git
synced 2026-02-26 04:42:22 +00:00
Fix boost::math::round to handle halfway cases correctly.
Update tests accordingly. Update boost::math::fmod docs to make sign and rounding direction clear. [SVN r61252]
This commit is contained in:
@@ -22,7 +22,7 @@ inline T round(const T& v, const Policy& pol)
|
||||
BOOST_MATH_STD_USING
|
||||
if(!(boost::math::isfinite)(v))
|
||||
return policies::raise_rounding_error("boost::math::round<%1%>(%1%)", 0, v, pol);
|
||||
return floor(v + 0.5f);
|
||||
return v < 0 ? static_cast<T>(ceil(v - 0.5f)) : static_cast<T>(floor(v + 0.5f));
|
||||
}
|
||||
template <class T>
|
||||
inline T round(const T& v)
|
||||
|
||||
Reference in New Issue
Block a user