2
0
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:
John Maddock
2010-04-13 16:50:46 +00:00
parent b3f10fe6ed
commit 7a7e393485
131 changed files with 672 additions and 656 deletions

View File

@@ -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)