|
Boost : |
From: Fernando Luis Cacciola Carballal (fcacciola_at_[hidden])
Date: 2001-11-05 11:07:37
--- In boost_at_y..., helmut.zeisel_at_a... wrote:
> --- In boost_at_y..., "Fernando Cacciola" <fcacciola_at_g...> wrote:
> > Hi,
> >
> > I uploaded a new version of the improved numeric_cast<>.
> >
> > http://groups.yahoo.com/group/boost/files/improved_numeric_cast
> >
> > It now works with bc5.5.1 and gcc2.95.2+
> >
> > I also uploaded the individual files along with the .zip archive.
> >
> > I'll appreciate any comments...
> >
>
> Here is one more comment from me:
>
> I get the impression that you changed the default
> behavior to rounding instead of truncating;
> i.e. numeric_cast<int>(5.7) == 6.
>
Yes, I did.
> I am not sure what the best choice for the
> default behavior should be,
> but I definitely need truncating.
>
I think that I was biased by my needs. But, on second thought, the
default behaviour of the built-in cast is truncation, so I guess you
are right and it should truncate by default.
> Is there a simple way to obtain truncating?
>
Yes.
In "numeric_cast_traits_detail.hpp",
In:
template<class T,class S,class range_checker>
struct rounding_converter
{
...
static S round ( arg_type s )
{
return s+half();
}
Change:
return s+half();
to:
return s ;
Best Regards,
Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk