Q:

How can I use the numbers to the right of a decimal point in a double?

My apologies if this question was asked already (I'm assuming that since it's a rather simple question and not because I didn't try to find it first!).

What I was trying to do is build a double number one char at a time.
The numbers to the left were easy with the line num = num * 10 + (c - '0'); /*num being the number built so far and c being the char added*/

but then doing something likenum = (double)((int)num) + ( (num%1)*10 + (c - '0') )/decDigits; //decDigits is the number of digits(including the new one) to the right of the decimal point

wouldn't work because apparently you can't use the % operator on a double.

What'd be the right way to achieve the above?

A:

Are you trying to convert a double to a string, or a string to a double? It looks like the latter, and I don’t think you should be using the % operator in that case at all. Starting at 0.1, multiply each digit’s value by what’s appropriate for its place.
It’s easier to explain in C, though:
char c;
double result = 0.0;

/* The part before the decimal place */
while ((c = *s++) && c != '.') {
    result = result * 10.0 + (c - '0');
}

/* The part after the decimal place */
if (c == '.') {
    double m = 0.1;
    s++;

    while ((c = *s++)) {
        result += m * (c - '0');
        m *= 0.1;
    }
}

