aboutsummaryrefslogtreecommitdiff
path: root/src/util/string.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/string.h')
-rw-r--r--src/util/string.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/util/string.h b/src/util/string.h
index 2f3c2615b..27e2f094d 100644
--- a/src/util/string.h
+++ b/src/util/string.h
@@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <string>
#include <cstring>
#include <vector>
+#include <limits>
#include <map>
#include <sstream>
#include <iomanip>
@@ -429,14 +430,11 @@ inline std::string itos(s32 i) { return std::to_string(i); }
/// Returns a string representing the decimal value of the 64-bit value \p i.
inline std::string i64tos(s64 i) { return std::to_string(i); }
-// std::to_string uses the '%.6f' conversion, which is inconsistent with
-// std::ostream::operator<<() and impractical too. ftos() uses the
-// more generic and std::ostream::operator<<()-compatible '%G' format.
-/// Returns a string representing the decimal value of the float value \p f.
+/// Returns a string representing the exact decimal value of the float value \p f.
inline std::string ftos(float f)
{
std::ostringstream oss;
- oss << f;
+ oss << std::setprecision(std::numeric_limits<float>::max_digits10) << f;
return oss.str();
}