fork(1) download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. int main () {
  7.  
  8. float val =31511.4424;
  9. stringstream ss (stringstream::in | stringstream::out);
  10.  
  11. ss << fixed << setprecision(2) << val;
  12.  
  13. string test = ss.str();
  14.  
  15. cout << test <<endl;
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
31511.44