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 -

Laravel mail error `Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [ #0]` -

c# SetCompatibleTextRenderingDefault must be called before the first -