Boost logo

Boost Users :

Subject: Re: [Boost-users] [numeric conversation] behavior on std::numeric_limits<double>::max() + eps with numeric_cast
From: Brandon Kohn (blkohn_at_[hidden])
Date: 2014-06-16 10:24:04


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);
    }
}

Cheers,

Brandon


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