Skip to content

Commit 2dadb80

Browse files
committed
Adding truncated decimal point for floats
open-source-parsers#397 Fix for above mentioned issue.
1 parent 9234cbb commit 2dadb80

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/lib_json/json_writer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ std::string valueToString(double value, bool useSpecialFloats, unsigned int prec
147147
// concepts of reals and integers.
148148
if (isfinite(value)) {
149149
len = snprintf(buffer, sizeof(buffer), formatString, value);
150+
if (len == 1) {
151+
len = snprintf(buffer, sizeof(buffer), "%.1f", value);
152+
}
150153
} else {
151154
// IEEE standard states that NaN values will not compare to themselves
152155
if (value != value) {

0 commit comments

Comments
 (0)