0^-1 divides by zero, shows random bn warning and kills dc. doesn't
happen with other div operators

also, requesting something like this just to workaround a warning
is counter productive, especially when you need a fraction during
an expression that involves exponentiation

...
s = scale
scale = 0
t = x / 1 /* round -Inf and get rid of scale to avoid
             superflous warning */
scale = s
...
y = (exp possibly containing division with fractions to keep) + z^t



Index: bcode.c
===================================================================
RCS file: /cvs/src/usr.bin/dc/bcode.c,v
retrieving revision 1.42
diff -u -r1.42 bcode.c
--- bcode.c     8 Mar 2012 08:15:37 -0000       1.42
+++ bcode.c     3 Nov 2012 18:39:11 -0000
@@ -1176,12 +1176,17 @@
                return;
        }
 
-       if (p->scale != 0)
-               warnx("Runtime warning: non-zero scale in exponent");
        normalize(p, 0);
 
        neg = false;
-       if (BN_cmp(p->number, &zero) < 0) {
+       if (BN_is_negative(p->number)) {
+               if (BN_is_zero(a->number)) {
+                       warnx("divide by zero");
+                       r = new_number();
+                       r->scale = bmachine.scale;
+                       push_number(r);
+                       return;
+               }
                neg = true;
                negate(p);
                scale = bmachine.scale;

Reply via email to