Boost logo

Boost :

Subject: Re: [boost] [math] potentian bug: iround throws, given double( numeric_limits<int>::min() )
From: Krzysztof Czainski (1czajnik_at_[hidden])
Date: 2011-10-21 06:37:19

2011/10/21 John Maddock <boost.regex_at_[hidden]>
> template <class R, class T>
> R round_to(const T&);
> template <class R, class T>
> R trunc_to(const T&);
> which would provide generic versions of iround/itrunc (although R need not
> be an integer type, as long as there's a static_cast from T to R).
> I'm not particularly sold on those names though, I guess
> "round_cast/trunc_cast" would be an alternative.
> John.

Personally, I prefer names "round_cast/trunc_cast", as they better describe
what's being done. I already use a function "round_to", that does something

template < class T >
T round_to( const T& x, const T& order )
  return round( x / order ) * order; // By the way, can this
be achieved more efficiently?

I'm not sure if "round_to" is the best name for this, but I think it is not
the right name for "round_cast" ;-)


Boost list run by bdawes at, gregod at, cpdaniel at, john at