commit 6f534ecd133ffd027a14597973f50b31bb0f7fa0 parent b63c06bf44decb57a1e901a53daabb8645a2acb8 Author: phoebos <ben@bvnf.space> Date: Mon, 31 Jan 2022 11:10:17 +0000 warn when rooting negative numbers Diffstat:
M | baddc.c | | | 6 | +++++- |
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/baddc.c b/baddc.c @@ -128,7 +128,11 @@ void power(void) { } void root(void) { - push((int)sqrt((double)pop())); + int a = pop(); + if (a < 0) { + fprintf(stderr, "root of negative number!\n"); + } + push((int)sqrt((double)a)); } struct {