I'm a little bit frustrated after I've found this strange atof/stof behavior
double bg = std::stof("1,24");
std::cerr<<"comma: "<<bg<<std::endl;
bg = std::stof("1.24");
std::cerr<<"dot: "<<bg<<std::endl;
when I change the string format, from comma to dot, this is what happens:
comma: 1.24
dot: 1
has anyone encountered this problem? thanks
bart
imbue
on the stream object and set a locale without that problem. You could also usestd::locale::global(std::locale("en_US.UTF-8"));
on your main function but this has a problem that any other thread of your app could change it. – Blagoveshchensk