96 ss << std::setprecision(3 + DBL_MANT_DIG - DBL_MIN_EXP);
101 ss << d + 0.5 / pow(10.0, g_precision);
105 ss << d - 0.5 / pow(10.0, g_precision);
108 std::string out(ss.str());
111 std::string::size_type end(out.find(
'.'));
112 if(end != std::string::npos
113 && out.length() > end + g_precision + 1)
116 out = out.substr(0, end + g_precision + 1);
118 if(out.find(
'.') != std::string::npos
119 && end != std::string::npos)
121 while(out.back() ==
'0')
123 out.erase(out.end() - 1);
125 if(out.back() ==
'.')
127 out.erase(out.end() - 1);
132 if(remove_leading_zero)
138 out.erase(out.begin());
141 else if(out.length() >= 4
146 out.erase(out.begin() + 1);