Equivalent of fprintf's -20.15g formatting with C++ formatted streams ?

K

Koen

Hi,
could anyone please tell me how I can get the equivalent of this:
fprintf(aFile,"-20.15g",aDouble);
but in C++ using formatted streams?
I tried with C++ formatted streams using:
aStream.width(20);
aStream.precision(15);
but then if there's a very small value, scientific notation is not used
automatically and precision is lost (like in 0.000000000000003 instead
of 3.33333333333e-15).
I must be missing something here...
Koen
 
V

Victor Bazarov

Koen said:
could anyone please tell me how I can get the equivalent of this:
fprintf(aFile,"-20.15g",aDouble);
but in C++ using formatted streams?
I tried with C++ formatted streams using:
aStream.width(20);
aStream.precision(15);
but then if there's a very small value, scientific notation is not used
automatically and precision is lost (like in 0.000000000000003 instead
of 3.33333333333e-15).
I must be missing something here...

What book are you reading? All the manipulators are there for you to
use. See 'scientific' or 'fixed', see 'left' and 'right'... IOW RTFM

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top