I would write this code if I were you:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string str = "-122.39381636393";
std::cout.precision(20);
cout << "setting longitude: " << stod(str) << endl;
return 0;
}
Basically, you would change things like:
precision for the printing
stod rather than low-level operation to get the double back from the string.
You can see it on ideone running.