# converting huge #'s in string format to double.

• 08-20-2003
ganonl
converting huge #'s in string format to double.
How do I properly convert huge numbers with decimal points
(ex. 14432454554.04524354) in string to double. I tried the function atof() but it has it's limits. Are there any other way?
• 08-20-2003
Hammer
For C way: http://www.rt.com/man/strtod.3.html

For a C++ way, try adapting this
• 08-20-2003
XSquared
sscanf( ).
• 08-20-2003
ganonl
strtod() function looks like it got all the numbers in the double, but
it change the number with an exponential notation.

Code:

```#include <iostream> #include <cstdlib> using namespace std; int main() {         char a[] = {"123423423.34343"};         char *b;         double d;         d = strtod(a, &b);         cout << d << endl;         system("PAUSE");         return 0; } //the result: 1.23423e+08 Press any key to continue . . .```
I'm doing a calculator program and I need to keep everything in order. How the heck am I suppose to output the right answer with the decimal period in the right place.
• 08-20-2003
XSquared
Code:

```#include <iostream> #include <cstdio> using namespace std; int main() {         char a[] = {"123423423.34343"};                 double d;                 sscanf( a, "%lf", &d );         cout << d << endl;                 system("PAUSE");         return 0; }```
• 08-20-2003
ganonl
I got the same result from your example XSquared.

I want this: 123423423.34343 on the output.
not 1.23423e+08
• 08-21-2003
Hammer
cout.precision( 20 );
cout << d << endl;
• 08-21-2003
ganonl
Thanks Hammer, didn't know about the precision() function.