I am looking for a way to convert double to string in c++ such that total number of digits remain to be 10 irrespective of how many are present before and after the decimal point and irrespective of the zeroes. Examples for better understanding:
0.00000000000000000000 =expected outcome> 0.0000000000
12345.00000000000000000 =expected outcome> 12345.00000
-15.123456789012 =expected outcome> -15.12345678
I couldnt find any relevant answer. For the methods like snprintf, std::setprecision with ostringstream, to_string, Boost's lexical_cast, some of the above case fails. Please help me, thanks.
Aucun commentaire:
Enregistrer un commentaire