mardi 24 mars 2015

Is std::to_string guaranteed to include a decimal point when converting floating point values?

With the below code,



int main() {
for(;;) {
float d;
cin >> d;
cout << std::to_string(d) << endl;
}
}


to_string seems to always return a string containing a decimal point followed by six digits. Is this behavior guaranteed (excluding nan and infinity)?


According to cplusplus.com , "as many digits are written as needed to represent the integral part, followed by the decimal-point character and six decimal digits".


Aucun commentaire:

Enregistrer un commentaire