Boost logo

Boost Users :

Subject: Re: [Boost-users] [numeric conversation] behavior on std::numeric_limits<double>::max() + eps with numeric_cast
From: Olaf Peter (ope-devel_at_[hidden])
Date: 2014-06-16 11:28:47


Am 16.06.2014 16:24, schrieb Brandon Kohn:
>
> On 6/16/2014 09:27 AM, Olaf Peter wrote:
>> so, I can't use it like boost.math.round
>> (<boost/math/special_functions/round.hpp>) with polycies or doubles,
>> isn't it?
> I don't think it (numeric_cast) should be used to round doubles. For
> that I would just call your rounder directly.
>
> I wouldn't recommend this, but if you really wanted to use numeric_cast
> due to other reasons, you could try specializing it for the double to
> double case:
>
> namespace boost
> {
> template <>
> double numeric_cast<double, double>(double value)
> {
> return boost::math::round(value);
> }
> }
>
>
My idea was to write a mathematical value class which can operate on
integers and floats using different rounding algorithms (hence
numeric_cast<int>(double from_sqrt) etc. ) and switch statically this
type to see later which better fits my needs. Initialized are this
values from boost.units where doubles are preferred as underlying type.
Probably I have to specialize this class for integers and floats.

Thanks,
Olaf


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net