What's the recommended way to format a float to a string without trailing zeros? to_string() returns "1.350000" as does sprintf. I don't want a fixed number of decimals..
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s = to_string(1.35);
cout << s << endl;
}
Aucun commentaire:
Enregistrer un commentaire