diff options
author | Gavin Howard <yzena.tech@gmail.com> | 2019-06-10 19:52:37 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-06-11 15:13:47 -0500 |
commit | 047be9a36e8b2243d0b06a722df72dc3fbc97bf5 (patch) | |
tree | 8eeb6797004ee95874589031289632d6063c3e42 | |
parent | 3eeda4f9293f8157d12d86e3b46d4bb4b45ab5c2 (diff) | |
download | toybox-047be9a36e8b2243d0b06a722df72dc3fbc97bf5.tar.gz |
bc: fix a bug in power
This bug is that an error should be returned when the user tries to take
0 to a negative power, since that is undefined, but bc would return 0.
-rw-r--r-- | toys/pending/bc.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/toys/pending/bc.c b/toys/pending/bc.c index bb5d86cb..b38d9872 100644 --- a/toys/pending/bc.c +++ b/toys/pending/bc.c @@ -1717,6 +1717,7 @@ static BcStatus bc_num_p(BcNum *a, BcNum *b, BcNum *c, size_t scale) { if (b->rdx) return bc_vm_err(BC_ERROR_MATH_NON_INTEGER); if (!b->len) { + if (b->neg) return bc_vm_err(BC_ERROR_MATH_DIVIDE_BY_ZERO); bc_num_one(c); return BC_STATUS_SUCCESS; } |