Boost C++ Libraries: Ticket #6047: functions round_cast and trunc_cast https://svn.boost.org/trac10/ticket/6047 <p> The functions are general versions of iround, and alike functions. </p> <pre class="wiki">template &lt; class R, class T, class Policy &gt; inline R round_cast( T const&amp; x, Policy const&amp; pol ) { BOOST_MATH_STD_USING T r = boost::math::round(x,pol); if( r &gt; boost::integer_traits&lt;R&gt;::const_max || r &lt; boost::integer_traits&lt;R&gt;::const_min ) return static_cast&lt;R&gt;( boost::math::policies::raise_rounding_error( "cz::ar::round_cast&lt;target_type,%1%&gt;(%1%)", 0, x, pol ) ); return static_cast&lt;R&gt;(r); } template &lt; class R, class T &gt; inline R round_cast( T const&amp; x ) { return round_cast&lt;R&gt;( x, boost::math::policies::policy&lt;&gt;() ); } </pre><p> Analogically for trunc()... </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6047 Trac 1.4.3 genevivewoo@… Thu, 24 Jan 2013 00:09:18 GMT attachment set https://svn.boost.org/trac10/ticket/6047 https://svn.boost.org/trac10/ticket/6047 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">ticket6047_round_trunc_01242013.patch</span> </li> </ul> <p> round &amp; trunc.hpp </p> Ticket Evelyn Wu <genevivewoo@…> Thu, 24 Jan 2013 00:12:09 GMT attachment set https://svn.boost.org/trac10/ticket/6047 https://svn.boost.org/trac10/ticket/6047 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">ticket6047_round_trunc_01242013.diff</span> </li> </ul> Ticket