If you want to control the precision then include #include <iomanip>
and use std::cout << std::setprecision(17);
to set the number of digits you want. Also float has 6 significant bits precision whereas double has 12. So whenever your string has more than 6 digits in decimal there is a possibility of loosing the precision.
7
solved Convert string into float in C++ with full Significant figures [Fixed working in Dev C++]