how to converse string to float without losing precision

I am trying to convert a string to float as follows:

int main()
{

string str_1="0.1913415";
float fl_1=atof(s);
printf("%f",fl_1);
}
the result showed is 0.191342; obviously ,the precision is lost.
who knows why?
float inherently has fairly low precision

If you need more precision use double, use strtod to get the value

http://www.cplusplus.com/reference/clibrary/cstdlib/strtod/
thanks!!!
Topic archived. No new replies allowed.