Skip to content

Instantly share code, notes, and snippets.

@binki
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save binki/324589b3ccee46a699a3 to your computer and use it in GitHub Desktop.
Save binki/324589b3ccee46a699a3 to your computer and use it in GitHub Desktop.
#include <sstream>
#include <iostream>
int main(int argc, const char *const argv [])
{
std::stringstream ss;
ss.precision(2);
int rounded_value = 4;
ss << std::fixed << (double)rounded_value;
std::string s = ss.str();
std::cout << s << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment