boost::lexical_cast
throws errors for values larger than the maximum value of double. But for numbers smaller than minimum value, it silently makes it zero. How do I enable out of range errors for later case(i.e. If a number is smaller than 2.22507e-308, then parser should throw some error)?
#include <iostream>
#include <limits>
#include <boost/lexical_cast.hpp>
int main()
{
std::cout<<boost::lexical_cast<long double>("1.5787658476e-400")<<'\n';
std::cout<<boost::lexical_cast<double>("1.5787658476e-400")<<'\n';
std::cout<<std::numeric_limits<double>::min()<<'\n';
try{
std::cout<<boost::lexical_cast<double>("1.5787658476e+400")<<'\n';
} catch(boost::bad_lexical_cast &e)
{
std::cout<<e.what()<<'\n';
}
std::cout<<std::numeric_limits<double>::max()<<'\n';
return 0;
}