Help with strtod()

I am having problems with the strtod() command giving me different values then what I am expecting. I even made just a little example code to test it out and it gace me the same issues. I am using it to convert the latitude and longitude strings into floats. But I am not getting the correct answer dunno why??

#include <string.h>
#include <ctype.h>
#include <stdio.h>

static FILE uartout = {0} ;
static int uart_putchar (char c, FILE *stream)
{
Serial.write(c) ;
return 0 ;
}

float lati;
char *lat = “2636.1191100”;
char * tok;

void setup(){

Serial.begin(9600);
// fill in the UART file descriptor with pointer to writer.
fdev_setup_stream (&uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE);
// The uart is the standard output device STDOUT.
stdout = &uartout ;

lati = strtod(lat,&tok);
// lati = strtod(lat,&lat);
//lati = atof (lat);
//lati = lati * 100000;
// printf(“begin”);
printf("%.1Ldf\n", lati);
Serial.println(lati,15);

}

void loop(){

}

I think I I can figure this out then I should be good. Dunno whats up with the printf here not so worried about that tho.

BTW it also does it with the Serial Print lemme put this version below with an output.

float lati;
char *lat = “2636.1191100”;
char * tok;

void setup(){

Serial.begin(9600);

lati = strtod(lat,&tok);
printf("%.1Ldf\n", lati);//forget about this for now
Serial.println(lati,15);

}

void loop(){

}

OUTPUT:
2636.118896484375000

So thats it if anyone has some feedback that would be great!

ardrolls:

char *lat = "2636.1191100";
2636.118896484375000

AVR-GCC does not implement double/long float, only float. What you declare as double is quietly handled as float. Float is 32-bit floating point and has a precision of about 6 significant figures. These two values are about as close to one another as two floats are likely to be.

24 bit mantissa means 7 significant figures and the result is out by about 1 part in 10^7