I want to print 12345.0 as 0.12345e+05. But the below code gives 1.23450e+04. Is there a way to control the format of std::scientific?
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
double a = 12345.0;
std::stringstream s;
s.precision(5);
s << scientific;
s << a;
cout << s.str() << endl;
return 0;
}
The output is
1.23450e+04
Aucun commentaire:
Enregistrer un commentaire