I am trying to convert a string to double, but my double is truncated at the third decimal point.
My line looks like this: "-122.39381636393" After converting it, 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: " << this->longitude << endl;
}
Output Example:
got longitude: -122.39381636393
setting longitude: -122.394
I want it to support all decimal points, any hints?
jshah source
share