String to Double conversion C++ [duplicate]
问题 This question already has answers here : How do I print a double value with full precision using cout? (10 answers) Closed 5 years ago . I'm trying to convert a string into a double but my double gets cut off at the 3rd decimal point. My string looks like this: "-122.39381636393" After it gets converted it looks like this: -122.394 void setLongitude(string longitude){ this->longitude = (double)atof(longitude.c_str()); cout << "got longitude: " << longitude << endl; cout << "setting longitude: