summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2018-12-22 21:45:18 +0100
committerDenys Vlasenko2018-12-22 21:45:18 +0100
commit2ea8ddf8c245dd160eacf35409572c28345506f7 (patch)
treea17cfa8d8a63045d47a10a8a1e72f91baf4a8404
parent1557b76edde8bc810f82ac67e3b83b2d6ccce51c (diff)
downloadbusybox-2ea8ddf8c245dd160eacf35409572c28345506f7.zip
busybox-2ea8ddf8c245dd160eacf35409572c28345506f7.tar.gz
bc: do not disallow powers to N.0000 degree - it's even shorter code
function old new delta zbc_num_p 440 424 -16 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 876244b..d7595ce 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -2089,7 +2089,8 @@ static FAST_FUNC BC_STATUS zbc_num_p(BcNum *a, BcNum *b, BcNum *restrict c, size
size_t i, powrdx, resrdx;
bool neg;
- if (b->rdx) RETURN_STATUS(bc_error("non integer number"));
+// GNU bc does not allow 2^2.0. We do.
+// if (b->rdx) RETURN_STATUS(bc_error("non integer number"));
if (b->len == 0) {
bc_num_one(c);
@@ -2109,9 +2110,10 @@ static FAST_FUNC BC_STATUS zbc_num_p(BcNum *a, BcNum *b, BcNum *restrict c, size
neg = b->neg;
b->neg = false;
-
s = zbc_num_ulong(b, &pow);
+ b->neg = neg;
if (s) RETURN_STATUS(s);
+ // b is not used beyond this point
bc_num_init(&copy, a->len);
bc_num_copy(&copy, a);
@@ -2123,7 +2125,6 @@ static FAST_FUNC BC_STATUS zbc_num_p(BcNum *a, BcNum *b, BcNum *restrict c, size
scale = a->rdx * pow;
}
- b->neg = neg;
for (powrdx = a->rdx; !(pow & 1); pow >>= 1) {
powrdx <<= 1;