I'm trying to convert a double to a string and can't get it to work. I've tried Convert.ToStrin g(...) and a few other permutations (System::Conver t.ToString(...) , etc), but nothing works. For some reason I keep getting back that Convert is not a part of the System namespace. Basically, the compiler can't recognize ToString() as a usable function. Any ideas on what's going wrong?
Double to String not working
Collapse
X
-
-
if you are using C++ you can functions in <sstream> to convert double, int, etc to a string, e.g.Originally posted by jwmaidenI've tried sprintf() and my doubles are being rounded. I'll go back and see what's going wrong there.
Any input on why Convert and ToString isn't working?
I have never heard of functions Convert and ToString in C/C++ - do you have a third party API?Code:double pi = 3.14159; ostringstream strout(ios_base::out); strout << pi << endl; cout << "pi as a string = " << strout.str() << endl;Comment
-
You are using .net and getting confused with the different languages.Originally posted by jwmaidenI've tried sprintf() and my doubles are being rounded. I'll go back and see what's going wrong there.
Any input on why Convert and ToString isn't working?Comment
-
No. Following your thinking in this thread leads me to the conclusion that you will only confuse yourself doing that. We can get the answer together right here. First can you give us the following info?
What compiler are you using?
What language are you using?Comment
-
-
Comment