diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-11-14 21:17:31 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-11-14 21:17:31 -0800 |
commit | c30a96120f53b960db56bc05a7ce6310bb2528f5 (patch) | |
tree | 09684ea3e25ac325977cf6f04b7658ef7089a49a /mpi | |
parent | 0c7ab22f4ea9541514782694ea2a64485d72f0a3 (diff) | |
download | txr-c30a96120f53b960db56bc05a7ce6310bb2528f5.tar.gz txr-c30a96120f53b960db56bc05a7ce6310bb2528f5.tar.bz2 txr-c30a96120f53b960db56bc05a7ce6310bb2528f5.zip |
Fix bug in bignum addition.
* mpi/mpi.c (s_mp_add): It looks like this function had the
same kind of bug I fixed years ago in the multiplication routines.
("fix-mult-bug" patch, originally). In the main loop, two digit-sized
values are added together to produce a partial sum with carry.
Unfortunately, both operands digit-sized, so the result is truncated to
the digit type. The cast of one of the operands to mp_word is missing.
Diffstat (limited to 'mpi')
-rw-r--r-- | mpi/mpi.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -4130,7 +4130,7 @@ mp_err s_mp_add(mp_int *a, mp_int *b) /* magnitude addition */ pa = DIGITS(a); pb = DIGITS(b); for(ix = 0; ix < used; ++ix) { - w += *pa + *pb++; + w += *pa + convert(mp_word, *pb++); *pa++ = ACCUM(w); w = CARRYOUT(w); } |