c++ - How to retain 0s after decimal point, after converting string to double -


#include <iostream>  using namespace std;  int main() {     string str="-1.2300";     double d = stod(str);     cout<<d<<"\n"; } 

output: -1.23

i expecting output following

-1.2300

if want, need use formatted output precision specifier:

printf("%.4f\n", d); 

or specify precision cout:

cout.precision(4); cout << fixed << d << "\n"; 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -