I am facing a conversion issue for which I'd like your help. I'm using gcc4 compiler and I am quite restricted to use gcc4.
I want to convert std::string to double.
std::string aQuantity = aRate.getQuantity();
std::string aAmount = aRate.getAmount();
// aAmount = "22.05"
double dQuantity = boost::lexical_cast<double>(aQuantity);
double dAmount = boost::lexical_cast<double> (aAmount);
// dAmount = 22.050000000000001
By the way, I also tried atof
and I still have the same issue. Is there any way to use istringstream
with setprecission(2)
to get the correct value shown by aAmount
?