aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-05 19:05:32 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-05 19:05:32 +0100
commitb3cb90124bcf1786710c200c00530fd3f213929d (patch)
tree19f26126ac8b71cb787ec07a1e81a7acce4f08a9
parent06fa65bd95455e97d2275ee4d74167f9bfd251c0 (diff)
downloadbusybox-w32-b3cb90124bcf1786710c200c00530fd3f213929d.tar.gz
busybox-w32-b3cb90124bcf1786710c200c00530fd3f213929d.tar.bz2
busybox-w32-b3cb90124bcf1786710c200c00530fd3f213929d.zip
bc: use unsigned division by 10 instead of signed
function old new delta bc_num_k 990 988 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to '')
-rw-r--r--miscutils/bc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 07793e9d4..6dc79118a 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -1657,7 +1657,7 @@ static BcStatus bc_num_k(BcNum *restrict a, BcNum *restrict b,
1657 a->len < BC_NUM_KARATSUBA_LEN || b->len < BC_NUM_KARATSUBA_LEN) 1657 a->len < BC_NUM_KARATSUBA_LEN || b->len < BC_NUM_KARATSUBA_LEN)
1658 { 1658 {
1659 size_t i, j, len; 1659 size_t i, j, len;
1660 int carry; 1660 unsigned carry;
1661 1661
1662 bc_num_expand(c, a->len + b->len + 1); 1662 bc_num_expand(c, a->len + b->len + 1);
1663 1663
@@ -1668,8 +1668,9 @@ static BcStatus bc_num_k(BcNum *restrict a, BcNum *restrict b,
1668 1668
1669 carry = 0; 1669 carry = 0;
1670 for (j = 0; j < a->len; ++j) { 1670 for (j = 0; j < a->len; ++j) {
1671 int in = (int) c->num[i + j]; 1671 unsigned in = c->num[i + j];
1672 in += ((int) a->num[j]) * ((int) b->num[i]) + carry; 1672 in += ((unsigned) a->num[j]) * ((unsigned) b->num[i]) + carry;
1673 // note: compilers prefer _unsigned_ div/const
1673 carry = in / 10; 1674 carry = in / 10;
1674 c->num[i + j] = (BcDig)(in % 10); 1675 c->num[i + j] = (BcDig)(in % 10);
1675 } 1676 }