Opened 11 years ago
#6047 new Feature Requests
functions round_cast and trunc_cast
| Reported by: | Owned by: | John Maddock | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | math |
| Version: | Boost Development Trunk | Severity: | Problem |
| Keywords: | Cc: |
Description
The functions are general versions of iround, and alike functions.
template < class R, class T, class Policy >
inline R round_cast( T const& x, Policy const& pol )
{
BOOST_MATH_STD_USING
T r = boost::math::round(x,pol);
if( r > boost::integer_traits<R>::const_max || r < boost::integer_traits<R>::const_min )
return static_cast<R>( boost::math::policies::raise_rounding_error(
"cz::ar::round_cast<target_type,%1%>(%1%)", 0, x, pol ) );
return static_cast<R>(r);
}
template < class R, class T >
inline R round_cast( T const& x )
{
return round_cast<R>( x, boost::math::policies::policy<>() );
}
Analogically for trunc()...
Attachments (2)
Change History (2)
by , 10 years ago
| Attachment: | ticket6047_round_trunc_01242013.patch added |
|---|
by , 10 years ago
| Attachment: | ticket6047_round_trunc_01242013.diff added |
|---|
Note:
See TracTickets
for help on using tickets.

round & trunc.hpp