|
|
@ -189,12 +189,19 @@ void Builder::putF64(double number, uint8_t precision) const |
|
|
|
// There is no number behind the decimal point
|
|
|
|
// There is no number behind the decimal point
|
|
|
|
if (dot == std::string::npos) { |
|
|
|
if (dot == std::string::npos) { |
|
|
|
if (precision > 0) { |
|
|
|
if (precision > 0) { |
|
|
|
converted += ".0"; |
|
|
|
converted += '.' + std::string(precision, '0'); |
|
|
|
} |
|
|
|
} |
|
|
|
m_builder << converted; |
|
|
|
m_builder << converted; |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If there are less numbers behind the decimal point than the precision
|
|
|
|
|
|
|
|
if (converted.length() < length) { |
|
|
|
|
|
|
|
converted += std::string(length - converted.length(), '0'); |
|
|
|
|
|
|
|
m_builder << converted; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Only round if there are more numbers behind the decimal point than the precision,
|
|
|
|
// Only round if there are more numbers behind the decimal point than the precision,
|
|
|
|
// or the number that comes after the maximum precision is higher than 4
|
|
|
|
// or the number that comes after the maximum precision is higher than 4
|
|
|
|
if (converted.length() > length && converted[length] > '4') { |
|
|
|
if (converted.length() > length && converted[length] > '4') { |
|
|
|