Output the whole value of a double

Discussion in 'C++' started by bsmith1111@isp.com, Mar 9, 2006.

  1. Guest

    I have a program that outputs the following to the screen (through
    visual c++)
    9999999999, which is stored in a double. I would like to keep the
    number the way it is, but every time I output it (after converting it
    to a cstring), it becomes 1e+010. I've tried many different formatting
    ways, including stringstream formatting, sprintf(buffer, "%25.0fl",
    temp) - temp is the double, sprintf(buffer, "%25f", temp), etc. I am
    using the double number in a calculator I've been working on (CString
    converted to chars for parsing, double result converted to string,
    string converted to cstring for messagebox update), and I've been
    unable to determine whether or not my many conversions were making this
    a problem (unless I'm missing something, the conversions do not change
    the display of the double - it's already like that). Can someone help
    me output the whole number 9999999999 (and others), and not the
    abbreviated 1e+010 form? Thanks for your help.
    , Mar 9, 2006
    #1
    1. Advertising

  2. wrote:
    > I have a program that outputs the following to the screen (through
    > visual c++)
    > 9999999999, which is stored in a double. I would like to keep the
    > number the way it is, but every time I output it (after converting it
    > to a cstring), it becomes 1e+010. I've tried many different formatting
    > ways, including stringstream formatting, sprintf(buffer, "%25.0fl",
    > temp) - temp is the double, sprintf(buffer, "%25f", temp), etc. I am
    > using the double number in a calculator I've been working on (CString
    > converted to chars for parsing, double result converted to string,
    > string converted to cstring for messagebox update), and I've been
    > unable to determine whether or not my many conversions were making this
    > a problem (unless I'm missing something, the conversions do not change
    > the display of the double - it's already like that). Can someone help
    > me output the whole number 9999999999 (and others), and not the
    > abbreviated 1e+010 form? Thanks for your help.
    >


    #include <iostream>
    #include <ios>
    #include <ostream>
    #include <iomanip>

    using namespace std;

    int main()
    {
    double nines = 9999999999;
    cout << fixed << setprecision(0) << nines << endl;
    }


    V
    --
    Please remove capital As from my address when replying by mail
    Victor Bazarov, Mar 9, 2006
    #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. Sydex
    Replies:
    12
    Views:
    6,472
    Victor Bazarov
    Feb 17, 2005
  2. \A_Michigan_User\
    Replies:
    2
    Views:
    881
    \A_Michigan_User\
    Aug 21, 2006
  3. David Marsh

    testing whether a double is a whole number

    David Marsh, Jul 3, 2005, in forum: C Programming
    Replies:
    3
    Views:
    605
    David Marsh
    Jul 3, 2005
  4. Siew Yee
    Replies:
    1
    Views:
    140
    clintonG
    Aug 13, 2005
  5. navin
    Replies:
    3
    Views:
    139
    navin
    Jun 24, 2009
Loading...

Share This Page