setprecision
sets the precision printed, not the precision of the double. strtod
reads in the double to the minimum of the precisions available in either the double or the string (bounded by the string, in this case).
In short, you already have the full precision of your string in lon1
by using strtod
.