I am finding that atof is limited in the size of a string that it will parse.
Example:
float num = atof("49966.73");
cout << num;
shows 49966.7
num = atof("499966.73");
cout << num;
shows 499966
I need something that will parse the whole string accurately, to a floating point number, not just the first 6 characters.
Use
std::setprecisionandstd::fixedfrom<iomanip>standard library, as mentioned in the comments, still, there will be conversion issues due to lack of precision offloattypes, for better results usedoubleandstd::stodfor conversion:The first prints
499966.72, the latter499966.73.