reading double from sd config file

I want to read a double from a config file.I have made this functions:

void Settings::readDouble(char buff,String data,bool flag,double dataToStore) {
    data = "";
    int intPart=0;
    int probablyFloatPart=0;

        while(buff != '\n') {
            if(isdigit(buff)) {
                data.concat(buff);
                Serial.println(data);
            } else if (buff == '.') {
                char charBuf[data.length()+1];
                data.toCharArray(charBuf,data.length()+1);
                // Convert chars to double
                intPart = atoi(charBuf);
                Serial.println(intPart);
                data="";
                flag = false;
            }
            buff = theSettings.read();
        };
        // Convert string to array of chars
        char charBuf[data.length()+1];
        data.toCharArray(charBuf,data.length()+1);
        // Convert chars to integer
        probablyFloatPart = atoi(charBuf);
        Serial.println(probablyFloatPart);
        if (!flag){
            dataToStore=intPart+(probablyFloatPart/pow(10,data.length()));
        }else{
            dataToStore=probablyFloatPart;
        }
        flag=true;
        //Serial.println(dataToStore,5);
}

From serial.printing i noticed that if the number i want to read has more than 4 digits on either int or decimal part it gives error.Basically i can not tranform a string with more than 4 bytes to a int. Any help?

Arduinos (except for the Due) uses 8-bit AVR processors internally, and the size of the int data type is 16-bits, which can hold values in the range of -32768 to +32767. The long data type is 32-bits, and can hold much larger values. Note, unlike other machines, on the AVR, double is only 32-bits and is equivalent to float. At the very least, you should use long data and use the atol function instead of atoi.

You might try using the standard atof function which takes a const char * argument and returns a double. However, I don’t know if the Arduino library fully supports these standard functions. I recall that some versions of the library had a different floating point conversion function, but when you used it, it would not work.

As written, your conversion function is not optimal, particularly using pow to convert the value (but also, you will be continually moving data about, and allocating data on the stack for temporary arrays, which might result in running out of stack). If it is available, you should use a standard function, which presumably the author has tuned for the environment.

Here is the atof manual page from my Linux system.

ATOF(3)                    Linux Programmer’s Manual                   ATOF(3)

NAME
       atof - convert a string to a double

SYNOPSIS
       #include <stdlib.h>

       double atof(const char *nptr);

DESCRIPTION
       The atof() function converts the initial portion of the string pointed to by nptr to double.  The behavior is the same as

           strtod(nptr, (char **) NULL);

       except that atof() does not detect errors.

RETURN VALUE
       The converted value.

CONFORMING TO
       SVr4, POSIX.1-2001, 4.3BSD, C89, C99.

SEE ALSO
       atoi(3), atol(3), strtod(3), strtol(3), strtoul(3)