diff options
| author | gingerBill <bill@gingerbill.org> | 2019-11-10 19:55:26 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2019-11-10 19:55:26 +0000 |
| commit | 8da8301b09ab56fefcd04887b1f9fd0571d241a9 (patch) | |
| tree | 3e8310670378a2d0f5557ad616b1537c84e01719 /src | |
| parent | 536cceeef9144b59a9e335d2bbb151ead3f7bdba (diff) | |
Fix big subtraction for very large numbers on edges of overflow.
Diffstat (limited to 'src')
| -rw-r--r-- | src/big_int.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/big_int.cpp b/src/big_int.cpp index dc3d50589..5b6b228a5 100644 --- a/src/big_int.cpp +++ b/src/big_int.cpp @@ -499,7 +499,7 @@ void big_int_add(BigInt *dst, BigInt const *x, BigInt const *y) { smaller = &neg_abs; break; default: - GB_PANIC("Invalid bit_int_cmp value"); + GB_PANIC("Invalid big_int_cmp value"); return; } @@ -530,6 +530,9 @@ void big_int_add(BigInt *dst, BigInt const *x, BigInt const *y) { if (sub_overflow_u64(v, prev_overflow, &v)) { found_word = true; overflow += 1; + } else { + // IMPORTANT TODO(bill): Is this mathematics correct here? + v += prev_overflow; } dst->d.words[i] = v; i += 1; |