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

This is a discussion on converting huge #'s in string format to double. within the C++ Programming forums, part of the General Programming Boards category; How do I properly convert huge numbers with decimal points (ex. 14432454554.04524354) in string to double. I tried the function ...

1. ## 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?

2. For C way: http://www.rt.com/man/strtod.3.html

For a C++ way, try adapting this

3. sscanf( ).

4. 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.

5. 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;
}

6. I got the same result from your example XSquared.

I want this: 123423423.34343 on the output.
not 1.23423e+08

7. cout.precision( 20 );
cout << d << endl;

8. Thanks Hammer, didn't know about the precision() function.