M
mathieu
Hi,
I am looking at the following example (*). Some compile seems to
output either
3.1416 2006 1e-010
3.14159e+000 2.00600e+003 1.00000e-010
or
3.1416 2006 1e-10
3.14159e+00 2.00600e+03 1.00000e-10
How do I check how many number of zero will be printed ? Or how do I
say "only use 2 digits" when exponent is < 100.
Thanks !
(*)
#include <iostream>
using namespace std;
int main () {
double a,b,c;
a = 3.1415926534;
b = 2006.0;
c = 1.0e-10;
cout.precision(5);
cout << a << '\t' << b << '\t' << c << endl;
cout << scientific << a << '\t' << b << '\t' << c << endl;
return 0;
}
I am looking at the following example (*). Some compile seems to
output either
3.1416 2006 1e-010
3.14159e+000 2.00600e+003 1.00000e-010
or
3.1416 2006 1e-10
3.14159e+00 2.00600e+03 1.00000e-10
How do I check how many number of zero will be printed ? Or how do I
say "only use 2 digits" when exponent is < 100.
Thanks !
(*)
#include <iostream>
using namespace std;
int main () {
double a,b,c;
a = 3.1415926534;
b = 2006.0;
c = 1.0e-10;
cout.precision(5);
cout << a << '\t' << b << '\t' << c << endl;
cout << scientific << a << '\t' << b << '\t' << c << endl;
return 0;
}