commit 54a886a217f53e4ddb7dba47c46b1747fcb3eb75
parent 8beb03f703a121fde00cfcb284f43fa9de5c4390
Author: Ed van Bruggen <edvb@uw.edu>
Date: Fri, 30 Mar 2018 21:49:23 -0700
Prevent division by zero
Diffstat:
1 file changed, 2 insertions(+), 0 deletions(-)
diff --git a/tisp.c b/tisp.c
@@ -205,6 +205,8 @@ MK_TYPE(Prim, pr, PRIMITIVE, mk_prim)
Val
mk_rat(int num, int den)
{
+ if (den == 0)
+ warn("division by zero");
frac_reduce(&num, &den);
if (den == 1) /* simplify fraction into integer if denominator is 1 */
return mk_int(num);