diff options
author | Thomas Van Lenten <thomasvl@google.com> | 2017-06-16 12:30:08 -0400 |
---|---|---|
committer | Thomas Van Lenten <thomasvl@google.com> | 2017-06-16 15:24:33 -0400 |
commit | dd19b876d4c9a604946f6c4e39cc4eac5f12cfb9 (patch) | |
tree | dabceb4c021d2916092a080c02f880facd222e94 /src | |
parent | 91bf623aa145cd1576451ed3764a64a089384ac4 (diff) | |
download | protobuf-dd19b876d4c9a604946f6c4e39cc4eac5f12cfb9.tar.gz protobuf-dd19b876d4c9a604946f6c4e39cc4eac5f12cfb9.tar.bz2 protobuf-dd19b876d4c9a604946f6c4e39cc4eac5f12cfb9.zip |
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')
-rw-r--r-- | src/google/protobuf/stubs/strutil.cc | 2 |
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); |