A Journey 2 Eternity

Converting double to a CString (0.005 to 5e-003)

Posted on: September 22, 2008

Input:

double d = 0.005;

CString strTemp;

strTemp.Format(“%.0e”,d);

Output : 5e-003

But if I want “5e-03 then

Input:

// Enable two-digit exponent format

unsigned int old_exponent_format;

old_exponent_format = _set_output_format(_TWO_DIGIT_EXPONENT);

double d = 0.005;

CString strTemp;

strTemp.Format(“%.0e”,d);

Output : 5e-03

Conversion to scientific notation is done automatically. But as far as I know “5e-3” is impossible.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Pages

Categories

September 2008
M T W T F S S
« Aug   Dec »
1234567
891011121314
15161718192021
22232425262728
2930  

Blog Stats

  • 26,968 hits
%d bloggers like this: