September 18th, 2003, 10:44 AM
anyone know of a function in the standard library that will expand a scientific number ?
change 1.503149e-03 to 0.00153149
which is the source to the power of -3
September 18th, 2003, 10:59 AM
Er.... there's no conversion necessary as the number remains the same -- the only difference is the way you write it out. Do you mean that you want to print it out in a different format? If so, then look at using cout.setf():
double foo = 0.00153149;
cout.precision(10); // Show up to 10 decimal places
cout << foo << endl; // print as 0.00153149
cout << foo << endl; // print as 1.503149e-03
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
September 18th, 2003, 11:50 AM
Sorry, two points I failed to mention, it has to be C and 1.503149e-03 is currently in a delimited text file that I am reading and will eventually write out to a new delimited text file expanded to 0.00153149
so now I need to look at fputs() to see how I can format it
September 18th, 2003, 03:10 PM
fputs() will not format for you. Create a string first and then fputs it.
Do the number formatting with sprintf. Here's a test program I ran:
OBTW, you have a typo in your message. 1.503149e-03 would be rewritten as 0.001503149, not as 0.00153149. You accidentally dropped the zero between the five and three.
double num = 1.503149e-03;
sprintf(buffer,"Num == %1.9f",num);
Num == 0.001503149
September 19th, 2003, 04:10 AM
Thanks dwise1_aol, thats excellent
and I had to look twice at the typo beforeI saw it :)