Hi,

When p->scale is not zero, bexp() calculates the same value twice, first
in split_number() and then in normalize().  This can be avoided by
simply reusing the result produced by the former.  (While here, also
fold a long line.)

Index: bcode.c
===================================================================
RCS file: /cvs/src/usr.bin/dc/bcode.c,v
retrieving revision 1.61
diff -u -p -r1.61 bcode.c
--- bcode.c     12 Dec 2017 19:07:10 -0000      1.61
+++ bcode.c     17 Dec 2017 13:18:15 -0000
@@ -1178,11 +1178,11 @@ bexp(void)
                bn_checkp(f);
                split_number(p, i, f);
                if (!BN_is_zero(f))
-                       warnx("Runtime warning: non-zero fractional part in 
exponent");
-               BN_free(i);
+                       warnx("Runtime warning: non-zero fractional part "
+                           "in exponent");
+               BN_free(p->number);
+               p->number = i;
                BN_free(f);
-
-               normalize(p, 0);
        }
 
        neg = BN_is_negative(p->number);

Regards,

kshe

Reply via email to