Boost logo

Boost Users :

Subject: [Boost-users] numeric_cast<float> throws for double infinity
From: Dmitry Volosnykh (dmitry.volosnykh_at_[hidden])
Date: 2016-03-09 09:12:46

When I try to cast variable of type double (which is equal to
std::numeric_limits<double>::inifinity()) to float I get
exception: std::bad_cast: bad numeric conversion: positive overflow.
I expected to get std::numeric_limits<float>::inifinity().
The same is true for negative infinity.

Is it intended behavior or bug? In case this should be considered as bug,
maybe it was fixed in more recent versions of Boost?

PS. I am using stock Boost 1.54 on Ubuntu 14.04


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at