Index: src/inspector/string-16.cc |
diff --git a/src/inspector/string-16.cc b/src/inspector/string-16.cc |
index e39b87c17f8f035201e9ea4b4835ea3da6c52800..f6084602f421085127603f146f2c9618eb1b1962 100644 |
--- a/src/inspector/string-16.cc |
+++ b/src/inspector/string-16.cc |
@@ -8,8 +8,10 @@ |
#include <cctype> |
#include <cstdlib> |
#include <cstring> |
+#include <iomanip> |
#include <limits> |
#include <locale> |
+#include <sstream> |
#include <string> |
#include "src/base/platform/platform.h" |
@@ -381,26 +383,19 @@ String16 String16::fromInteger(size_t number) { |
// static |
String16 String16::fromDouble(double number) { |
- const size_t kBufferSize = 100; |
- char buffer[kBufferSize]; |
- v8::base::OS::SNPrintF(buffer, kBufferSize, "%f", number); |
- return String16(buffer); |
+ std::ostringstream s; |
+ s.imbue(std::locale("C")); |
+ s << std::fixed << std::setprecision(std::numeric_limits<double>::digits10) |
+ << number; |
+ return String16(s.str().c_str()); |
} |
// static |
-String16 String16::fromDoublePrecision3(double number) { |
- const size_t kBufferSize = 100; |
- char buffer[kBufferSize]; |
- v8::base::OS::SNPrintF(buffer, kBufferSize, "%.3g", number); |
- return String16(buffer); |
-} |
- |
-// static |
-String16 String16::fromDoublePrecision6(double number) { |
- const size_t kBufferSize = 100; |
- char buffer[kBufferSize]; |
- v8::base::OS::SNPrintF(buffer, kBufferSize, "%.6g", number); |
- return String16(buffer); |
+String16 String16::fromDouble(double number, int precision) { |
+ std::ostringstream s; |
+ s.imbue(std::locale("C")); |
+ s << std::fixed << std::setprecision(precision) << number; |
+ return String16(s.str().c_str()); |
} |
int String16::toInteger(bool* ok) const { |