Output the whole value of a double

B

bsmith1111

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.
 
V

Victor Bazarov

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top