I'm working on a homework/project to tokenize a set of operands (double) and operators as inputs. It's been going well enough and I have been able to finish it by implementing my own tokenizer but when I tested my output exe with digits greater than 7 I get a random output, which probably means I got "fresh" memory location (eg 123456 is OK, but 1234567 and higher digit numbers are no good).
Here's a code snippet:

token::token(istream& f)
    string g;
    int gpos=0;
    //checks for presence of a decimal point
    bool thereisadecimal=false;
                //checks for decimal points to check if invalid input
                    //checks if value has already been set 
                    //     (it's on a loop for scan)
                    _type = operand_;
                    _value = strtod(g.c_str(),NULL);

When I try the inputs greater than six digits I get erroneous outputs. Why is this happening and is there a way to go around this?

Do you have a specific test case?

Are you sure it's not something like
1234567 being displayed as say 1.23456E6 (for example).

I'm sorry. this was a stupid question. I am VERY SORRY!!!

I hadn't realized that the output was set in scientific notation. *smacks face on a math, physics, and computer science book*

really sorry. will double check for own stupidity next time I'm tempted to post.

This question has already been answered. Start a new discussion instead.