Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Equivalent of fprintf's -20.15g formatting with C++ formatted streams ?

Reply
Thread Tools

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

 
 
Koen
Guest
Posts: n/a
 
      10-05-2004
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


 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      10-05-2004
Koen wrote:
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Binary vs. formatted std::string reading/writing to streams Leslaw Bieniasz C++ 2 01-15-2010 11:53 PM
Text formatting with streams CSpartan C++ 7 07-24-2005 08:57 PM
Need formatting options menu for formatting hard drive Mark T. Computer Support 3 11-24-2003 11:50 PM
How do I get nicely-formatted times? Leif K-Brooks Firefox 1 11-20-2003 10:22 PM
Re: printf-style formatting with streams. Joe Hotchkiss C++ 1 06-23-2003 10:53 PM



Advertisments