commit a604396ad2fa4099caa02948a19804b14b0111ee
parent 9e5cddd29b87aaf3b02a69c6d6bc8aa5daf19d8d
Author: Ed van Bruggen <edvb@uw.edu>
Date: Tue, 2 Jun 2020 00:31:49 -0700
Fix power op to sometimes return exact expression
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tibs/math.c b/tibs/math.c
@@ -199,8 +199,8 @@ prim_pow(Tsp st, Hash vars, Val args)
EVAL_CHECK(p, car(cdr(args)), "pow", EXPRESSION);
bnum = pow(num(b), num(p)/den(p));
bden = pow(den(b), num(p)/den(p));
- if (bnum == (int)bnum && bden == (int)bden &&
- b->t & NUMBER && p->t & NUMBER)
+ if ((bnum == (int)bnum && bden == (int)bden) ||
+ b->t & DECIMAL || p->t & DECIMAL)
return mk_num(b->t, p->t, 0)(bnum, bden);
return mk_pair(mk_sym(st, "^"), mk_pair(b, mk_pair(p, st->nil)));
}