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

Discussion in 'C++' started by Koen, Oct 5, 2004.

  1. Koen

    Koen Guest

    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
     
    Koen, Oct 5, 2004
    #1
    1. Advertising

  2. Re: Equivalent of fprintf's -20.15g formatting with C++ formattedstreams ?

    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
     
    Victor Bazarov, Oct 5, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joe Hotchkiss
    Replies:
    1
    Views:
    1,224
  2. Replies:
    2
    Views:
    450
    Barry Schwarz
    Jan 2, 2004
  3. Magix

    fprintf formatted output

    Magix, Jul 27, 2004, in forum: C Programming
    Replies:
    6
    Views:
    316
  4. fprintf formatting question???

    , May 20, 2005, in forum: C Programming
    Replies:
    7
    Views:
    677
  5. Leslaw Bieniasz
    Replies:
    2
    Views:
    1,086
    Thomas J. Gritzan
    Jan 15, 2010
Loading...

Share This Page