aboutsummaryrefslogtreecommitdiff
path: root/src/lib_json/json_tool.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib_json/json_tool.h')
-rw-r--r--src/lib_json/json_tool.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lib_json/json_tool.h b/src/lib_json/json_tool.h
index 2d7b7d9..b952c19 100644
--- a/src/lib_json/json_tool.h
+++ b/src/lib_json/json_tool.h
@@ -116,14 +116,18 @@ template <typename Iter> void fixNumericLocaleInput(Iter begin, Iter end) {
* Return iterator that would be the new end of the range [begin,end), if we
* were to delete zeros in the end of string, but not the last zero before '.'.
*/
-template <typename Iter> Iter fixZerosInTheEnd(Iter begin, Iter end) {
+template <typename Iter>
+Iter fixZerosInTheEnd(Iter begin, Iter end, unsigned int precision) {
for (; begin != end; --end) {
if (*(end - 1) != '0') {
return end;
}
// Don't delete the last zero before the decimal point.
- if (begin != (end - 1) && *(end - 2) == '.') {
- return end;
+ if (begin != (end - 1) && begin != (end - 2) && *(end - 2) == '.') {
+ if (precision) {
+ return end;
+ }
+ return end - 2;
}
}
return end;