浏览代码

bugfix: don't underflow for thousands separator for things with less than three digits to begin with.

Sam Jaffe 4 年之前
父节点
当前提交
598cbbe846
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/bignum_helper.cpp

+ 1 - 1
src/bignum_helper.cpp

@@ -154,7 +154,7 @@ std::string apply(number_format const & fmt, std::string text) {
   auto decimal_place = text.find('.');
   if (fmt.separate_thousands) {
     constexpr std::size_t const LEN_THOUSAND{3};
-    auto pos = std::min(text.size(), decimal_place);
+    auto pos = std::max(std::min(text.size(), decimal_place), LEN_THOUSAND);
     for (pos -= LEN_THOUSAND; pos > LEN_THOUSAND; pos -= LEN_THOUSAND) {
       text.insert(pos, ",");
     }