Jul 26, 2016 at 12:28pm UTC
Hello,
i have this string with two decimal places: "16.33", but whether i use atof,
stof or stold, i get 16.3 as a return.
some ideas on how to get the 16.33 ?
thanks
Jul 26, 2016 at 12:36pm UTC
If your string is a C++ std::string, you can use the "convert from string" functions: std::stof, std::stod or std::stold. The conversions require a C++11 (or above) compiler.
http://www.cplusplus.com/reference/string/stof/
http://www.cplusplus.com/reference/string/stod/
http://www.cplusplus.com/reference/string/stold/
Jul 26, 2016 at 1:39pm UTC
yeah this is what i was doing. but actually it works, value of my string was "16.3" and not "16.33" due to early stop in reading a file...
thanks anyway !