aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/stubs/strutil.cc
diff options
context:
space:
mode:
authorGravatar Thomas Van Lenten <thomasvl@google.com>2017-06-16 12:30:08 -0400
committerGravatar Thomas Van Lenten <thomasvl@google.com>2017-06-16 15:24:33 -0400
commitdd19b876d4c9a604946f6c4e39cc4eac5f12cfb9 (patch)
treedabceb4c021d2916092a080c02f880facd222e94 /src/google/protobuf/stubs/strutil.cc
parent91bf623aa145cd1576451ed3764a64a089384ac4 (diff)
Raise the number of digits used for floats.
About 1.5% of all IEEE754 single-precision numbers require nine decimal digits to represent accurately.
Diffstat (limited to 'src/google/protobuf/stubs/strutil.cc')
-rw-r--r--src/google/protobuf/stubs/strutil.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc
index 336894b5..1a4d71c8 100644
--- a/src/google/protobuf/stubs/strutil.cc
+++ b/src/google/protobuf/stubs/strutil.cc
@@ -1401,7 +1401,7 @@ char* FloatToBuffer(float value, char* buffer) {
float parsed_value;
if (!safe_strtof(buffer, &parsed_value) || parsed_value != value) {
int snprintf_result =
- snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG+2, value);
+ snprintf(buffer, kFloatToBufferSize, "%.*g", FLT_DIG+3, value);
// Should never overflow; see above.
GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize);