Hello, This patch fixes a bug in power in bc; 0 to any negative power should be an error, but bc returns 0. This bug is my bad.
Gavin Howard
From 4aab9295913d8fcf7f3082d51b97b8b679655379 Mon Sep 17 00:00:00 2001 From: Gavin Howard <[email protected]> Date: Mon, 10 Jun 2019 19:52:37 -0600 Subject: [PATCH] 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. --- toys/pending/bc.c | 1 + 1 file changed, 1 insertion(+) 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; } -- 2.17.1
_______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
