浏览代码

Fixing bounds issue with negative numbers that use all 9 digits in the first cell.

Samuel Jaffe 8 年之前
父节点
当前提交
ea28819179
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/biginteger.cpp

+ 1 - 1
src/biginteger.cpp

@@ -181,7 +181,7 @@ bool math::operator> (biginteger const & rhs, biginteger const & lhs) {
 biginteger const biginteger::ZERO{0}, biginteger::ONE{1}, biginteger::NEGATIVE_ONE{-1};
 
 std::string biginteger::to_string() const {
-  std::vector<char> output(biginteger::SEG_DIGITS * data.size() + 1, '\0');
+  std::vector<char> output(biginteger::SEG_DIGITS * data.size() + 2, '\0');
   std::ptrdiff_t idx = 0;
   if (is_negative) { output[0] = '-'; ++idx; }
   idx += sprintf(output.data() + idx, "%d", data[data.size()-1]);