(arith_driver, float_arith_driver): Compute (- x) by
authorPaul Eggert <eggert@twinsun.com>
Sat, 29 Aug 1998 17:57:22 +0000 (17:57 +0000)
committerPaul Eggert <eggert@twinsun.com>
Sat, 29 Aug 1998 17:57:22 +0000 (17:57 +0000)
using negation, not subtraction; this makes a difference with
IEEE floating point arithmetic (and also if integer arithmetic
is ones' complement or signed-magnitude!).

src/data.c

index 9d3955d..cb04426 100644 (file)
@@ -2203,9 +2203,7 @@ arith_driver (code, nargs, args)
        {
        case Aadd: accum += next; break;
        case Asub:
-         if (!argnum && nargs != 1)
-           next = - next;
-         accum -= next;
+         accum = argnum ? accum - next : nargs == 1 ? - next : next;
          break;
        case Amult: accum *= next; break;
        case Adiv:
@@ -2265,9 +2263,7 @@ float_arith_driver (accum, argnum, code, nargs, args)
          accum += next;
          break;
        case Asub:
-         if (!argnum && nargs != 1)
-           next = - next;
-         accum -= next;
+         accum = argnum ? accum - next : nargs == 1 ? - next : next;
          break;
        case Amult:
          accum *= next;