lundi 2 décembre 2019

Problem with converting string to double C++ [duplicate]

This question already has an answer here:

After conversion from stringstream to double, in double variable a lot of symbols.

   std::string myStr = "37.61";
   stringstream stStream;
   double dValue = 0.0;
   stStream << myStr;
   stStream >> dValue;

In the variable dValue is placed 37.609999999999999

I need 37.61

std::fixed and std::setprecision(2) dont help

Aucun commentaire:

Enregistrer un commentaire