mercredi 3 mai 2017

std::stof does not work

What I am trying to do is to convert std::string to a float value.

std::string test = "0.003906";
float testf = std::stof(test);
qDebug() << testf;

This always gives me 0.

std::string test = "1";
int testf = std::stoi(test);
qDebug() << testf;

This gives me proper value 1. What can be the problem here?

Environment:

  • g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
  • Qt5.7.0

Aucun commentaire:

Enregistrer un commentaire