how do you output a double without exponents?

How do you output a simple calculation (below) without the result being displayed as number * 10 to the power of x?

eg:
//-- begin code
double x = 12345;
x *= 123;

cout << x;
//-- end code

This snippet of code outputs to the console the answer "1.51844e+06", how do i make it display that answer in an expanded form ie. "1518435"???

Comments

  • This is the closest I know how to do:
    [code]
    #include

    int main(void) {
    double x = 12345.0 * 123.0;

    std::cout.setf(std::ios_base::fixed);
    std::cout << x << std::endl;

    return 0;
    }
    [/code]
    But I don't know how to clip the trailing zeroes. Tested in GCC 3.0.4.
  • : This is the closest I know how to do:
    : But I don't know how to clip the trailing zeroes. Tested in GCC 3.0.4.
    [code]
    #include
    using std::cout;
    using std::endl;
    using std::ios;
    #include
    using std::setiosflags;
    using std::setprecision;

    int main(){
    double x = 12345.0 * 123.0;

    cout << setiosflags(ios::fixed) << setprecision(0) << x << endl;


    return 0;
    }[/code]


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories