Click to See Complete Forum and Search --> : How convert a exponent double data to a string?


vector
April 24th, 1999, 07:29 AM
Hello
.
.
double i=1.2e21;
CString j;
.
.
I want j equal "1.2e21",how can I get that?
Thanks in advance.


Programe is very interesting!
Markup

Danielle Harvey
April 24th, 1999, 08:54 AM
To convert a double to a string, you do

char str[80];
double a = 32433.2321;
sprintf(str, "%f", a);

The second argument, which in this case is "%f", can be formatted just
like the printf format.

Hope this helps.

Danielle

Danielle Harvey
April 24th, 1999, 08:55 AM
Also, to copy then to CString format use strcpy so

strcpy(j, str);

vector
April 24th, 1999, 08:03 PM
Thanks a lot.
But the length of the string is very short,so when I finish the convertion I want to keep the exponent format in the string.
like
.
double i=2.3e300;
CString j;//its length is 10 chars.
.
In my program j must have the form
" 2.3e300",how can do that?
thanks.

vector

vector
April 24th, 1999, 08:12 PM
using sprintf(...,%e,...),I get it.
Thanks!

vector