This outputs 4.894e+009 for the value. How can I have it output 4894000000 instead?Code:double var = 4894000000;
cout<<var;
Printable View
This outputs 4.894e+009 for the value. How can I have it output 4894000000 instead?Code:double var = 4894000000;
cout<<var;
I guess you could break the number up into smaller number such as 48940 and 00000 then you won't get the errors and in a console you can't tell the difference :)
So there's no other way to do it?
Try something like cout << setwidth(20) << dValue << endl;
Heresy:
You CAN use stdio in console mode programs.
cout is not ansi c. C++ supports ansi c, almost mostly.PHP Code:#include <stdio.h>
printf( "my big number = %f\n", var);
or
char t[80];
sprinf(t,"%f",var);
printf("%s\n",t);
or (non-ansi)
Cstring str;
str.format("%f",var);
cout << str;
The reason cout isn't ANSI C is because it's ANSI C++ :p
You can use stdio, but there's no point if you're using iostreams, which you should be in C++ programs.