return returns nan

Hello,
I am quite a beginner, so the answer to my problem might be quite simple, but I cannot find any solution by searching.

I wrote a main function, calling an object and using a method of this object. This method should return a double, but all I get is nan.

This troubles me a bit, as a made a cout directly before the return in this function and there I get a correct value.
Here some of the code:

Main:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
int main(){
	string ausdruck;	
	cout << "Bitte geben Sie den zu integrierenden Ausdruck ein:\n";
	getline(cin, ausdruck);
	double leftborder;
	double rightborder;
	double stepwidth;
	cout << "Bitte geben Sie die untere Integrationsgrenze ein:\n";
	cin >> leftborder;
	cout << "Bitte geben Sie die obere Integrationsgrenze ein:\n";
	cin >> rightborder;
	cout << "Bitte geben Sie die Schrittweite ein:\n";
	cin >> stepwidth;
	Integral* integral = new Integral(ausdruck,leftborder,rightborder,stepwidth);
	double ergebnis;
	ergebnis = integral->ReturnValue();
	cout << "Ergebnis:" << ergebnis << "\n";
	}


The point were there should be returned something:

1
2
3
4
5
6
7
8
9
10
11
12
if(working.find(")") == std::string::npos){
		//Eventuelle Reste des letzten Durchlaufs in Value löschen
		value = 0;
		
		//TEST
		cout << "Do I get in here?\n";
		
		value = Evaluate(working);
		cout <<"Should be: "<<value<<"\n";
		return value;
		
	}


value is declared in the whole function. I get an "Do I get in here?", so I enter the if-clause, I get a "Should be: <<any double>>", but the function calling in main only gives nan.

So where did I make a really stupid mistake?

Thanks for any answers.

greetings

tiris
Well, it returns double. NaN is a special value of double.
Read this: http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=integersReals
I am really sorry, but now I compiled the above code anew and it works. I did it on a different machine, but I thought I did not use any system specific code, so I am puzzled.

So sorry for giving trouble.

greetings
tiris
Topic archived. No new replies allowed.