No scientific notation?

Discussion in 'C++' started by Ville Ahonen, Oct 19, 2004.

  1. Ville Ahonen

    Ville Ahonen Guest

    I'm a total beginner at C++ so please bear with me.. When i write

    cout << stddev * stddev << endl;

    I get the output "4.49513e-05". How can I rephrase the above so that I
    would instead get the output "0.000049513"?

    Thanks alot,

    Ville
    Ville Ahonen, Oct 19, 2004
    #1
    1. Advertising

  2. "Ville Ahonen" <> wrote in message
    news:aQ4dd.3829$...
    > I'm a total beginner at C++ so please bear with me.. When i write
    >
    > cout << stddev * stddev << endl;
    >
    > I get the output "4.49513e-05". How can I rephrase the above so that I
    > would instead get the output "0.000049513"?
    >


    cout << fixed << stddev*stddev << endl;

    john
    John Harrison, Oct 19, 2004
    #2
    1. Advertising

  3. Ville Ahonen

    Mike Wahler Guest

    "John Harrison" <> wrote in message
    news:...
    >
    > "Ville Ahonen" <> wrote in message
    > news:aQ4dd.3829$...
    > > I'm a total beginner at C++ so please bear with me.. When i write
    > >
    > > cout << stddev * stddev << endl;
    > >
    > > I get the output "4.49513e-05". How can I rephrase the above so that I
    > > would instead get the output "0.000049513"?
    > >

    >
    > cout << fixed << stddev*stddev << endl;


    To elaborate:

    You can also use 'setprecision(n)' to control the
    number of digits after the decimal point.

    'std::fixed' is declared by <ios>, and
    'std::setprecision()' is declared by <iomanip>

    -Mike
    Mike Wahler, Oct 19, 2004
    #3
    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. Dustan

    Scientific Notation

    Dustan, Dec 4, 2005, in forum: Python
    Replies:
    7
    Views:
    13,434
    Dustan
    Dec 4, 2005
  2. grinder

    reguarding scientific notation

    grinder, Aug 28, 2006, in forum: C Programming
    Replies:
    7
    Views:
    444
    Knemon
    Aug 29, 2006
  3. asdf
    Replies:
    2
    Views:
    534
    Rolf Magnus
    Oct 21, 2006
  4. N1GHTS

    Scientific Notation Conversion

    N1GHTS, Feb 20, 2008, in forum: C Programming
    Replies:
    1
    Views:
    564
    N1GHTS
    Feb 20, 2008
  5. Paul McNett

    Unexpected scientific notation

    Paul McNett, Jan 8, 2009, in forum: Python
    Replies:
    10
    Views:
    657
    Mark Dickinson
    Jan 9, 2009
Loading...

Share This Page