Index: mp.c
===================================================================
--- mp.c	(revision 2167)
+++ mp.c	(working copy)
@@ -61,9 +61,9 @@
 static int mp_compare_mp_to_mp(const int *, const int *);
 static int pow_ii(int, int);
 
-static void mpadd2(int *, int *, int *, int *, int);
-static void mpadd3(int *, int *, int, int, int *);
-static void mpaddq(int *, int, int, int *);
+static void mpadd2(const int *, const int *, int *, int, int);
+static void mpadd3(const int *, const int *, int, int, int *);
+static void mp_add_fraction(const int *, int, int, int *);
 static void mpart1(int, int *);
 static void mpchk(int , int );
 static float mp_cast_to_float(const int *);
@@ -77,7 +77,7 @@
 static void mpmlp(int *, int *, int *, int *);
 static void mpmul2(int *, int, int *, int);
 static void mpmulq(int *, int, int, int *);
-static void mpnzr(int *, int *, int *, int);
+static void mpnzr(int, int *, int *, int);
 static void mpovfl(int *);
 static void mprec(int *, int *);
 static void mproot(int *, int, int *);
@@ -96,50 +96,46 @@
 }
 
 
-void
-mpadd(int *x, int *y, int *z)
-{
 
 /*  ADDS X AND Y, FORMING RESULT IN Z, WHERE X, Y AND Z ARE MP
  *  NUMBERS.  FOUR GUARD DIGITS ARE USED, AND THEN R*-ROUNDING.
  */
-    mpadd2(x, y, z, y, 0);
+void
+mp_add(const int *x, const int *y, int *z)
+{
+    mpadd2(x, y, z, y[0], 0);
 }
 
-/*  CALLED BY MPADD, MPSUB ETC.
- *  X, Y AND Z ARE MP NUMBERS, Y1 AND TRUNC ARE INTEGERS.
- *  TO FORCE CALL BY REFERENCE RATHER THAN VALUE/RESULT, Y1 IS
- *  DECLARED AS AN ARRAY, BUT ONLY Y1(1) IS EVER USED.
- *  SETS Z = X + Y1(1)*ABS(Y), WHERE Y1(1) = +- Y(1).
- *  IF TRUNC.EQ.0 R*-ROUNDING IS USED, OTHERWISE TRUNCATION.
+/*  CALLED BY MP_ADD, MP_SUBTRACT ETC.
+ *  X, Y AND Z ARE MP NUMBERS, Y_SIGN AND TRUNC ARE INTEGERS.
+ *  SETS Z = X + Y_SIGN*ABS(Y), WHERE Y_SIGN = +- Y[0].
+ *  IF TRUNC == 0 R*-ROUNDING IS USED, OTHERWISE TRUNCATION.
  *  R*-ROUNDING IS DEFINED IN KUKI AND CODI, COMM. ACM
  *  16(1973), 223.  (SEE ALSO BRENT, IEEE TC-22(1973), 601.)
  *  CHECK FOR X OR Y ZERO
  */
 static void
-mpadd2(int *x, int *y, int *z, int *y1, int trunc)
+mpadd2(const int *x, const int *y, int *z, int y_sign, int trunc)
 {
-    int i__2;
+    int sign_prod;
+    int exp_diff, exp_result, med;
 
-    int j, s;
-    int ed, re, rs, med;
-
     /* X = 0 OR NEGLIGIBLE, SO RESULT = +-Y */
     if (x[0] == 0) {
         mp_set_from_mp(y, z);
-        z[0] = y1[0];
+        z[0] = y_sign;
         return;
     }
 
     /* Y = 0 OR NEGLIGIBLE, SO RESULT = X */    
-    if (y1[0] == 0) {
+    if (y_sign == 0  ||  y[0] == 0) {
         mp_set_from_mp(x, z);
         return;
     }
 
     /* COMPARE SIGNS */
-    s = x[0] * y1[0];
-    if (C_abs(s) > 1) {
+    sign_prod = y_sign * x[0];
+    if (C_abs(sign_prod) > 1) {
         mpchk(1, 4);
         if (v->MPerrors) {
             FPRINTF(stderr, "*** SIGN NOT 0, +1 OR -1 IN MPADD2 CALL.\nPOSSIBLE OVERWRITING PROBLEM ***\n");
@@ -149,61 +145,68 @@
         return;
     }
 
+
+
     /* COMPARE EXPONENTS */
-    ed = x[1] - y[1];
-    med = C_abs(ed);
-    if (ed < 0) {
-        /* HERE EXPONENT(Y) .GE. EXPONENT(X) */
+    exp_diff = x[1] - y[1];
+    med = C_abs(exp_diff);
+    if (exp_diff < 0) {
+        /* HERE EXPONENT(Y)  >  EXPONENT(X) */
         if (med > MP.t) {
+	  /* 'y' so much larger than 'x' that 'x+-y = y'.  Warning:
+	     still true with rounding??  */
             mp_set_from_mp(y, z);
-            z[0] = y1[0];
+            z[0] = y_sign;
             return;
+	}
+        goto L10;
+    } else if (exp_diff > 0) {
+        /* HERE EXPONENT(X)  >  EXPONENT(Y) */
+        if (med > MP.t) {
+	  /* 'x' so much larger than 'y' that 'x+-y = x'.  Warning:
+	     still true with rounding??  */
+            mp_set_from_mp(x, z);
+            return;
         }
-    } else if (ed == 0) {
+        goto L20;
+    } else {
         /* EXPONENTS EQUAL SO COMPARE SIGNS, THEN FRACTIONS IF NEC. */
-        if (s <= 0) {
-            for (j = 1; j <= MP.t; ++j) {
-                if ((i__2 = x[j + 1] - y[j + 1]) < 0)
-                    goto L100;
-                else if (i__2 == 0)
-                    continue;
-                else
-                    goto L130;
+        if (sign_prod < 0) {
+	    /* signs are not equal.  find out which mantissa is
+	       larger. */
+	    int j;
+            for (j = 2; j <= MP.t + 1; j++) {
+	        int i = x[j] - y[j];
+                if (i < 0)
+                    goto L10;
+                else if (i > 0)
+                    goto L20;
             }
 
-            /* RESULT IS ZERO */
+            /* both mantissas equal, so result is zero. */
             z[0] = 0;
             return;
         }
-    } else {
-        /* ABS(X) .GT. ABS(Y) */
-        if (med > MP.t) {
-            mp_set_from_mp(x, z);
-            return;
-        }
-        goto L130;
     }
-
-L100:
-    rs = y1[0];
-    re = y[1];
-    mpadd3(x, y, s, med, &re);
+    
+L10:
+    exp_result = y[1];
+    mpadd3(x, y, sign_prod, med, &exp_result);
     /* NORMALIZE, ROUND OR TRUNCATE, AND RETURN */
-    mpnzr(&rs, &re, z, trunc);
+    mpnzr(y_sign, &exp_result, z, trunc);
     return;
 
-L130:
-    rs = x[0];
-    re = x[1];
-    mpadd3(y, x, s, med, &re);
+L20:
+    exp_result = x[1];
+    mpadd3(y, x, sign_prod, med, &exp_result);
     /* NORMALIZE, ROUND OR TRUNCATE, AND RETURN */
-    mpnzr(&rs, &re, z, trunc);
+    mpnzr(x[0], &exp_result, z, trunc);
     return;
 }
 
 /* CALLED BY MPADD2, DOES INNER LOOPS OF ADDITION */
 static void
-mpadd3(int *x, int *y, int s, int med, int *re)
+mpadd3(const int *x, const int *y, int s, int med, int *re)
 {
     int i__1;
 
@@ -355,11 +358,11 @@
  *  CHECK LEGALITY OF B, T, M AND MXR
  */
 void
-mpaddi(int *x, int iy, int *z)
+mp_add_integer(const int *x, int iy, int *z)
 {
     mpchk(2, 6);
     mp_set_from_integer(iy, &MP.r[MP.t + 4]);
-    mpadd(x, &MP.r[MP.t + 4], z);
+    mp_add(x, &MP.r[MP.t + 4], z);
 }
 
 
@@ -368,11 +371,11 @@
  *  CHECK LEGALITY OF B, T, M AND MXR
  */
 static void
-mpaddq(int *x, int i, int j, int *y)
+mp_add_fraction(const int *x, int i, int j, int *y)
 {
     mpchk(2, 6);
     mp_set_from_fraction(i, j, &MP.r[MP.t + 4]);
-    mpadd(x, &MP.r[MP.t + 4], y);
+    mp_add(x, &MP.r[MP.t + 4], y);
 }
 
 
@@ -445,9 +448,9 @@
 
     MP.t = ts;
 
-/* ADD TO SUM, USING MPADD2 (FASTER THAN MPADD) */
+/* ADD TO SUM */
 
-    mpadd2(&MP.r[i2 - 1], y, y, y, 0);
+    mp_add(&MP.r[i2 - 1], y, y);
     if (MP.r[i2 - 1] != 0) goto L30;
 
 L60:
@@ -481,8 +484,8 @@
         i2 = i3 - (MP.t + 2);
         mp_set_from_integer(1, &MP.r[i2 - 1]);
         mp_set_from_mp(&MP.r[i2 - 1], &MP.r[i3 - 1]);
-        mpsub(&MP.r[i2 - 1], x, &MP.r[i2 - 1]);
-        mpadd(&MP.r[i3 - 1], x, &MP.r[i3 - 1]);
+        mp_subtract(&MP.r[i2 - 1], x, &MP.r[i2 - 1]);
+        mp_add(&MP.r[i3 - 1], x, &MP.r[i3 - 1]);
         mpmul(&MP.r[i2 - 1], &MP.r[i3 - 1], &MP.r[i3 - 1]);
         mproot(&MP.r[i3 - 1], -2, &MP.r[i3 - 1]);
         mpmul(x, &MP.r[i3 - 1], y);
@@ -554,9 +557,9 @@
 
     q <<= 1;
     mpmul(&MP.r[i3 - 1], &MP.r[i3 - 1], &y[1]);
-    mpaddi(&y[1], 1, &y[1]);
+    mp_add_integer(&y[1], 1, &y[1]);
     mpsqrt(&y[1], &y[1]);
-    mpaddi(&y[1], 1, &y[1]);
+    mp_add_integer(&y[1], 1, &y[1]);
     mpdiv(&MP.r[i3 - 1], &y[1], &MP.r[i3 - 1]);
     goto L20;
 
@@ -579,7 +582,7 @@
     mpmulq(&MP.r[i3 - 1], -i, i + 2, &MP.r[i3 - 1]);
     i += 2;
     MP.t = ts;
-    mpadd(&y[1], &MP.r[i3 - 1], &y[1]);
+    mp_add(&y[1], &MP.r[i3 - 1], &y[1]);
     if (MP.r[i3 - 1] != 0) goto L40;
 
 /* RESTORE T, CORRECT FOR ARGUMENT REDUCTION, AND EXIT */
@@ -631,30 +634,18 @@
 
 /* CHECK SIGN */
 
-    if (dx < 0.) goto L20;
-    else if (dx == 0) goto L10;
-    else goto L30;
+    if (dx < 0.)  {
+      rs = -1;
+      dj = -dx;
+    } else if (dx > 0.)  {
+      rs = 1;
+      dj = dx;
+    } else {
+      z[1] = 0;
+      return;
+    } 
 
-/* IF DX = 0D0 RETURN 0 */
 
-L10:
-    z[1] = 0;
-    return;
-
-/* DX .LT. 0D0 */
-
-L20:
-    rs = -1;
-    dj = -dx;
-    goto L40;
-
-/* DX .GT. 0D0 */
-
-L30:
-    rs = 1;
-    dj = dx;
-
-L40:
     ie = 0;
 
 L50:
@@ -695,7 +686,7 @@
 
 /* NORMALIZE RESULT */
 
-    mpnzr(&rs, &re, &z[1], 0);
+    mpnzr(rs, &re, &z[1], 0);
 
 /* Computing MAX */
 
@@ -894,7 +885,7 @@
 void
 mpcmf(int *x, int *y)
 {
-    int i, x2, il, ip, xs;
+    int i, x2, il, ip;
 
     /* RETURN 0 IF X = 0 */    
     if (x[0] == 0) {
@@ -931,10 +922,9 @@
         ip = i + MP.t;
         MP.r[ip - 1] = 0;
     }
-    xs = x[0];
 
     /* NORMALIZE RESULT AND RETURN */
-    mpnzr(&xs, &x2, y, 1);
+    mpnzr(x[0], &x2, y, 1);
 }
 
 
@@ -1256,7 +1246,7 @@
     mppi(&MP.r[i2 - 1]);
     mpdivi(&MP.r[i2 - 1], 2, &MP.r[i2 - 1]);
     --MP.t;
-    mpsub(&MP.r[i2 - 1], &y[1], &y[1]);
+    mp_subtract(&MP.r[i2 - 1], &y[1], &y[1]);
     mpsin(&y[1], &y[1]);
     return;
 
@@ -1300,7 +1290,7 @@
     MP.m += 2;
     mpexp(&MP.r[i2 - 1], &MP.r[i2 - 1]);
     mprec(&MP.r[i2 - 1], &y[1]);
-    mpadd(&MP.r[i2 - 1], &y[1], &y[1]);
+    mp_add(&MP.r[i2 - 1], &y[1], &y[1]);
 
 /*  RESTORE M.  IF RESULT OVERFLOWS OR UNDERFLOWS, MPDIVI WILL
  *  ACT ACCORDINGLY.
@@ -1424,7 +1414,7 @@
 
 /* NORMALIZE RESULT */
 
-    mpnzr(&rs, &re, &z[1], 0);
+    mpnzr(rs, &re, &z[1], 0);
 
 /* Computing MAX */
 
@@ -1660,7 +1650,7 @@
 /* NORMALIZE AND ROUND RESULT */
 
 L120:
-    mpnzr(&rs, &re, &z[1], 0);
+    mpnzr(rs, &re, &z[1], 0);
     return;
 
 /* HERE NEED SIMULATED DOUBLE-PRECISION DIVISION */
@@ -1812,7 +1802,7 @@
 /* USE MPEXP1 HERE */
 
     mpexp1(&x[1], &y[1]);
-    mpaddi(&y[1], 1, &y[1]);
+    mp_add_integer(&y[1], 1, &y[1]);
     return;
 
 /*  SEE IF ABS(X) SO LARGE THAT EXP(X) WILL CERTAINLY OVERFLOW
@@ -1871,7 +1861,7 @@
 
     MP.r[i3 - 1] = xs * MP.r[i3 - 1];
     mpexp1(&MP.r[i3 - 1], &y[1]);
-    mpaddi(&y[1], 1, &y[1]);
+    mp_add_integer(&y[1], 1, &y[1]);
 
 /*  COMPUTE E-2 OR 1/E USING TWO EXTRA DIGITS IN CASE ABS(X) LARGE
  *  (BUT ONLY ONE EXTRA DIGIT IF T .LT. 4)
@@ -1899,7 +1889,7 @@
     ++i;
     mpdivi(&MP.r[i2 - 1], i * xs, &MP.r[i2 - 1]);
     MP.t = ts;
-    mpadd2(&MP.r[i3 - 1], &MP.r[i2 - 1], &MP.r[i3 - 1], &
+    mpadd2(&MP.r[i3 - 1], &MP.r[i2 - 1], &MP.r[i3 - 1],
             MP.r[i2 - 1], 0);
     if (MP.r[i2 - 1] != 0) goto L80;
 
@@ -1908,7 +1898,7 @@
 L90:
     MP.t = ts;
     if (xs > 0) {
-        mpaddi(&MP.r[i3 - 1], 2, &MP.r[i3 - 1]);
+        mp_add_integer(&MP.r[i3 - 1], 2, &MP.r[i3 - 1]);
     }
     mppwr(&MP.r[i3 - 1], ix, &MP.r[i3 - 1]);
 
@@ -2048,7 +2038,7 @@
     ++i;
     mpdivi(&MP.r[i3 - 1], i, &MP.r[i3 - 1]);
     MP.t = ts;
-    mpadd2(&MP.r[i3 - 1], &y[1], &y[1], &y[1], 0);
+    mpadd2(&MP.r[i3 - 1], &y[1], &y[1], y[1], 0);
     if (MP.r[i3 - 1] != 0) goto L70;
 
 L80:
@@ -2059,7 +2049,7 @@
 
     i__1 = q;
     for (i = 1; i <= i__1; ++i) {
-        mpaddi(&y[1], 2, &MP.r[i2 - 1]);
+        mp_add_integer(&y[1], 2, &MP.r[i2 - 1]);
         mpmul(&MP.r[i2 - 1], &y[1], &y[1]);
     }
 }
@@ -2217,7 +2207,7 @@
 /* LOOP TO GET APPROXIMATE LN(X) USING SINGLE-PRECISION */
 
 L30:
-    mpaddi(&MP.r[i2 - 1], -1, &MP.r[i3 - 1]);
+    mp_add_integer(&MP.r[i2 - 1], -1, &MP.r[i3 - 1]);
 
 /* IF POSSIBLE GO TO CALL MPLNS */
 
@@ -2238,7 +2228,7 @@
 
 /* UPDATE Y AND COMPUTE ACCURATE EXP OF APPROXIMATE LOG */
 
-    mpsub(&y[1], &MP.r[i3 - 1], &y[1]);
+    mp_subtract(&y[1], &MP.r[i3 - 1], &y[1]);
     mpexp(&MP.r[i3 - 1], &MP.r[i3 - 1]);
 
 /* COMPUTE RESIDUAL WHOSE LOG IS STILL TO BE FOUND */
@@ -2260,7 +2250,7 @@
 
 L50:
     mplns(&MP.r[i3 - 1], &MP.r[i3 - 1]);
-    mpadd(&y[1], &MP.r[i3 - 1], &y[1]);
+    mp_add(&y[1], &MP.r[i3 - 1], &y[1]);
 }
 
 
@@ -2313,11 +2303,11 @@
     ts = MP.t;
     mp_set_from_mp(&x[1], &MP.r[i3 - 1]);
     mpdivi(&x[1], 4, &MP.r[i2 - 1]);
-    mpaddq(&MP.r[i2 - 1], -1, 3, &MP.r[i2 - 1]);
+    mp_add_fraction(&MP.r[i2 - 1], -1, 3, &MP.r[i2 - 1]);
     mpmul(&x[1], &MP.r[i2 - 1], &MP.r[i2 - 1]);
-    mpaddq(&MP.r[i2 - 1], 1, 2, &MP.r[i2 - 1]);
+    mp_add_fraction(&MP.r[i2 - 1], 1, 2, &MP.r[i2 - 1]);
     mpmul(&x[1], &MP.r[i2 - 1], &MP.r[i2 - 1]);
-    mpaddi(&MP.r[i2 - 1], -1, &MP.r[i2 - 1]);
+    mp_add_integer(&MP.r[i2 - 1], -1, &MP.r[i2 - 1]);
     mpmul(&x[1], &MP.r[i2 - 1], &y[1]);
 
 /* START NEWTON ITERATION USING SMALL T, LATER INCREASE */
@@ -2333,9 +2323,9 @@
 L40:
     mpexp1(&y[1], &MP.r[i4 - 1]);
     mpmul(&MP.r[i3 - 1], &MP.r[i4 - 1], &MP.r[i2 - 1]);
-    mpadd(&MP.r[i4 - 1], &MP.r[i2 - 1], &MP.r[i4 - 1]);
-    mpadd(&MP.r[i3 - 1], &MP.r[i4 - 1], &MP.r[i4 - 1]);
-    mpsub(&y[1], &MP.r[i4 - 1], &y[1]);
+    mp_add(&MP.r[i4 - 1], &MP.r[i2 - 1], &MP.r[i4 - 1]);
+    mp_add(&MP.r[i3 - 1], &MP.r[i4 - 1], &MP.r[i4 - 1]);
+    mp_subtract(&y[1], &MP.r[i4 - 1], &y[1]);
     if (MP.t >= ts) goto L60;
 
 /*  FOLLOWING LOOP COMPUTES NEXT VALUE OF T TO USE.
@@ -2535,7 +2525,7 @@
 /* NORMALIZE AND ROUND RESULT */
 
 L60:
-    mpnzr(&rs, &re, &z[1], 0);
+    mpnzr(rs, &re, &z[1], 0);
     return;
 
 L70:
@@ -2671,7 +2661,7 @@
 /* NORMALIZE AND ROUND OR TRUNCATE RESULT */
 
 L100:
-    mpnzr(&rs, &re, &z[1], trunc);
+    mpnzr(rs, &re, &z[1], trunc);
     return;
 
 /* HERE J IS TOO LARGE FOR SINGLE-PRECISION MULTIPLICATION */
@@ -2785,7 +2775,7 @@
 
 
 static void
-mpnzr(int *rs, int *re, int *z, int trunc)
+mpnzr(int rs, int *re, int *z, int trunc)
 {
     int i__1;
 
@@ -2793,14 +2783,14 @@
 
 /*  ASSUMES LONG (I.E. (T+4)-DIGIT) FRACTION IN
  *  R, SIGN = RS, EXPONENT = RE.  NORMALIZES,
- *  AND RETURNS MP RESULT IN Z.  INTEGER ARGUMENTS RS AND RE
- *  ARE NOT PRESERVED. R*-ROUNDING IS USED IF TRUNC.EQ.0
+ *  AND RETURNS MP RESULT IN Z.  INTEGER ARGUMENTS RE IS
+ *  NOT PRESERVED. R*-ROUNDING IS USED IF TRUNC == 0
  */
 
     --z;                 /* Parameter adjustments */
 
     i2 = MP.t + 4;
-    if (*rs != 0) goto L20;
+    if (rs != 0) goto L20;
 
 /* STORE ZERO IN Z */
 
@@ -2811,7 +2801,7 @@
 /* CHECK THAT SIGN = +-1 */
 
 L20:
-    if (C_abs(*rs) <= 1) goto L40;
+    if (C_abs(rs) <= 1) goto L40;
 
     if (v->MPerrors) {
         FPRINTF(stderr, "*** SIGN NOT 0, +1 OR -1 IN CALL TO MPNZR.\nPOSSIBLE OVERWRITING PROBLEM ***\n");
@@ -2922,7 +2912,7 @@
 
 /* STORE RESULT IN Z */
 
-    z[1] = *rs;
+    z[1] = rs;
     z[2] = *re;
     i__1 = MP.t;
     for (i = 1; i <= i__1; ++i) z[i + 2] = MP.r[i - 1];
@@ -2968,10 +2958,8 @@
 void
 mppi(int *x)
 {
-    float r__1;
-
     int i2;
-    float rx;
+    float prec;
 
 /*  SETS MP X = PI TO THE AVAILABLE PRECISION.
  *  USES PI/4 = 4.ARCTAN(1/5) - ARCTAN(1/239).
@@ -2980,8 +2968,6 @@
  *  CHECK LEGALITY OF B, T, M AND MXR
  */
 
-    --x;                /* Parameter adjustments */
-
     mpchk(3, 8);
 
 /* ALLOW SPACE FOR MPART1 */
@@ -2989,14 +2975,14 @@
     i2 = (MP.t << 1) + 7;
     mpart1(5, &MP.r[i2 - 1]);
     mpmuli(&MP.r[i2 - 1], 4, &MP.r[i2 - 1]);
-    mpart1(239, &x[1]);
-    mpsub(&MP.r[i2 - 1], &x[1], &x[1]);
-    mpmuli(&x[1], 4, &x[1]);
+    mpart1(239, x);
+    mp_subtract(&MP.r[i2 - 1], x, x);
+    mpmuli(x, 4, x);
 
 /* RETURN IF ERROR IS LESS THAN 0.01 */
 
-    rx = mp_cast_to_float(&x[1]);
-    if ((r__1 = rx - (float)3.1416, dabs(r__1)) < (float) 0.01) return;
+    prec = dabs(mp_cast_to_float(x) - 3.1416);
+    if (prec < 0.01) return;
 
 /* FOLLOWING MESSAGE MAY INDICATE THAT B**(T-1) IS TOO SMALL */
 
@@ -3009,7 +2995,7 @@
 
 
 void
-mppwr(int *x, int n, int *y)
+mppwr(const int *x, int n, int *y)
 {
     int i2, n2, ns;
 
@@ -3023,36 +3009,28 @@
 
     i2 = MP.t + 5;
     n2 = n;
-    if (n2 < 0)  goto L20;
-    else if (n2 == 0) goto L10;
-    else              goto L40;
-
-/* N = 0, RETURN Y = 1. */
-
-L10:
-    mp_set_from_integer(1, &y[1]);
-    return;
-
-/* N .LT. 0 */
-
-L20:
-    mpchk(4, 10);
-    n2 = -n2;
-    if (x[1] != 0) goto L60;
-
-    if (v->MPerrors) {
+    if (n2 < 0) {
+      /* N < 0 */
+      mpchk(4, 10);
+      n2 = -n2;
+      if (x[1] != 0) goto L60;
+      
+      if (v->MPerrors) {
         FPRINTF(stderr, "*** ATTEMPT TO RAISE ZERO TO NEGATIVE POWER IN CALL TO SUBROUTINE MPPWR ***\n");
+      }
+      
+      mperr();
+      goto L50;
+    } else if (n2 == 0) {
+      /* N == 0, RETURN Y = 1. */
+      mp_set_from_integer(1, &y[1]);
+      return;
+    } else  {
+      /* N > 0 */
+      mpchk(2, 6);
+      if (x[1] != 0) goto L60;
     }
 
-    mperr();
-    goto L50;
-
-/* N .GT. 0 */
-
-L40:
-    mpchk(2, 6);
-    if (x[1] != 0) goto L60;
-
 /* X = 0, N .GT. 0, SO Y = 0 */
 
 L50:
@@ -3172,7 +3150,7 @@
 
     mpchk(4, 10);
 
-/* MPADDI REQUIRES 2T+6 WORDS. */
+/* MP_ADD_INTEGER REQUIRES 2T+6 WORDS. */
 
     i2 = (MP.t << 1) + 7;
     i3 = i2 + MP.t + 2;
@@ -3226,7 +3204,7 @@
 
 L30:
     mpmul(&x[1], &MP.r[i2 - 1], &MP.r[i3 - 1]);
-    mpaddi(&MP.r[i3 - 1], -1, &MP.r[i3 - 1]);
+    mp_add_integer(&MP.r[i3 - 1], -1, &MP.r[i3 - 1]);
 
 /* TEMPORARILY REDUCE T */
 
@@ -3237,7 +3215,7 @@
 /* RESTORE T */
 
     MP.t = ts3;
-    mpsub(&MP.r[i2 - 1], &MP.r[i3 - 1], &MP.r[i2 - 1]);
+    mp_subtract(&MP.r[i2 - 1], &MP.r[i3 - 1], &MP.r[i2 - 1]);
     if (MP.t >= ts) goto L50;
 
 /*  FOLLOWING LOOP ALMOST DOUBLES T (POSSIBLE
@@ -3427,7 +3405,7 @@
 L120:
     mppwr(&MP.r[i2 - 1], np, &MP.r[i3 - 1]);
     mpmul(&x[1], &MP.r[i3 - 1], &MP.r[i3 - 1]);
-    mpaddi(&MP.r[i3 - 1], -1, &MP.r[i3 - 1]);
+    mp_add_integer(&MP.r[i3 - 1], -1, &MP.r[i3 - 1]);
 
 /* TEMPORARILY REDUCE T */
 
@@ -3439,7 +3417,7 @@
 /* RESTORE T */
 
     MP.t = ts3;
-    mpsub(&MP.r[i2 - 1], &MP.r[i3 - 1], &MP.r[i2 - 1]);
+    mp_subtract(&MP.r[i2 - 1], &MP.r[i3 - 1], &MP.r[i2 - 1]);
 
 /*  FOLLOWING LOOP ALMOST DOUBLES T (POSSIBLE BECAUSE
  *  NEWTONS METHOD HAS 2ND ORDER CONVERGENCE).
@@ -3639,13 +3617,13 @@
         mpart1(5, &MP.r[i3 - 1]);
         mpmuli(&MP.r[i3 - 1], 4, &MP.r[i3 - 1]);
         mpart1(239, y);
-        mpsub(&MP.r[i3 - 1], y, &y[1]);
+        mp_subtract(&MP.r[i3 - 1], y, &y[1]);
         mpdiv(&MP.r[i2 - 1], y, &MP.r[i2 - 1]);
         mpdivi(&MP.r[i2 - 1], 8, &MP.r[i2 - 1]);
         mpcmf(&MP.r[i2 - 1], &MP.r[i2 - 1]);
 
         /* SUBTRACT 1/2, SAVE SIGN AND TAKE ABS */
-        mpaddq(&MP.r[i2 - 1], -1, 2, &MP.r[i2 - 1]);
+        mp_add_fraction(&MP.r[i2 - 1], -1, 2, &MP.r[i2 - 1]);
         xs = -xs * MP.r[i2 - 1];
         if (xs == 0) {
             y[0] = 0;
@@ -3657,7 +3635,7 @@
 
         /* IF NOT LESS THAN 1, SUBTRACT FROM 2 */
         if (MP.r[i2] > 0)  {
-            mpaddi(&MP.r[i2 - 1], -2, &MP.r[i2 - 1]);
+            mp_add_integer(&MP.r[i2 - 1], -2, &MP.r[i2 - 1]);
         }
 
         if (MP.r[i2 - 1] == 0) {
@@ -3672,7 +3650,7 @@
          *  POWER SERIES, ELSE COMPUTE COS OF COMPLEMENT
          */
         if (MP.r[i2] > 0) {
-            mpaddi(&MP.r[i2 - 1], -2, &MP.r[i2 - 1]);
+            mp_add_integer(&MP.r[i2 - 1], -2, &MP.r[i2 - 1]);
             mpmul(&MP.r[i2 - 1], y, &MP.r[i2 - 1]);
             mpsin1(&MP.r[i2 - 1], y, 0);
         } else {
@@ -3778,12 +3756,12 @@
 
         i += 2;
         MP.t = ts;
-        mpadd2(&MP.r[i2 - 1], y, y, y, 0);
+        mpadd2(&MP.r[i2 - 1], y, y, *y, 0);
     } while(MP.r[i2 - 1] != 0);
 
     MP.t = ts;
     if (is == 0)
-        mpaddi(y, 1, y);
+        mp_add_integer(y, 1, y);
 }
 
 /*  RETURNS Y = SINH(X) FOR MP NUMBERS X AND Y, X NOT TOO LARGE.
@@ -3812,9 +3790,9 @@
     if (MP.r[i3] <= 0) {
         i2 = i3 - (MP.t + 2);
         mpexp1(&MP.r[i3 - 1], &MP.r[i2 - 1]);
-        mpaddi(&MP.r[i2 - 1], 2, &MP.r[i3 - 1]);
+        mp_add_integer(&MP.r[i2 - 1], 2, &MP.r[i3 - 1]);
         mpmul(&MP.r[i3 - 1], &MP.r[i2 - 1], y);
-        mpaddi(&MP.r[i2 - 1], 1, &MP.r[i3 - 1]);
+        mp_add_integer(&MP.r[i2 - 1], 1, &MP.r[i3 - 1]);
         mpdiv(y, &MP.r[i3 - 1], y);
     }
     /*  HERE ABS(X) .GE. 1, IF TOO LARGE MPEXP GIVES ERROR MESSAGE
@@ -3824,7 +3802,7 @@
         MP.m += 2;
         mpexp(&MP.r[i3 - 1], &MP.r[i3 - 1]);
         mprec(&MP.r[i3 - 1], y);
-        mpsub(&MP.r[i3 - 1], y, y);
+        mp_subtract(&MP.r[i3 - 1], y, y);
 
         /*  RESTORE M.  IF RESULT OVERFLOWS OR UNDERFLOWS, MPDIVI AT
          *  STATEMENT 30 WILL ACT ACCORDINGLY.
@@ -3892,12 +3870,9 @@
  *  FOUR GUARD DIGITS ARE USED, AND THEN R*-ROUNDING
  */
 void
-mpsub(int *x, int *y, int *z)
+mp_subtract(const int *x, const int *y, int *z)
 {
-    int y1[1];
-
-    y1[0] = -y[0];
-    mpadd2(x, y, z, y1, 0);
+    mpadd2(x, y, z, -y[0], 0);
 }
 
 
@@ -3939,13 +3914,13 @@
     if (MP.r[i2] > 0) {
         /* HERE ABS(X) .GE. 1/2 SO USE MPEXP */
         mpexp(&MP.r[i2 - 1], &MP.r[i2 - 1]);
-        mpaddi(&MP.r[i2 - 1], -1, y);
-        mpaddi(&MP.r[i2 - 1], 1, &MP.r[i2 - 1]);
+        mp_add_integer(&MP.r[i2 - 1], -1, y);
+        mp_add_integer(&MP.r[i2 - 1], 1, &MP.r[i2 - 1]);
         mpdiv(y, &MP.r[i2 - 1], y);
     } else {
         /* HERE ABS(X) .LT. 1/2, SO USE MPEXP1 TO AVOID CANCELLATION */
         mpexp1(&MP.r[i2 - 1], &MP.r[i2 - 1]);
-        mpaddi(&MP.r[i2 - 1], 2, y);
+        mp_add_integer(&MP.r[i2 - 1], 2, y);
         mpdiv(&MP.r[i2 - 1], y, y);
     }
 
Index: mp.h
===================================================================
--- mp.h	(revision 2167)
+++ mp.h	(working copy)
@@ -41,8 +41,10 @@
 void mp_abs(const int *, int *);
 void mp_invert_sign(const int *, int *);
 
-void mpadd(int *, int *, int *);
-void mpaddi(int *, int, int *);
+void mp_add(const int *, const int *, int *);
+void mp_add_integer(const int *, int, int *);
+void mp_subtract(const int *, const int *, int *);
+
 void mpasin(int *, int *);
 void mpatan(int *, int *);
 void mpcmf(int *, int *);
@@ -56,13 +58,12 @@
 void mpmul(int *, int *, int *);
 void mpmuli(int *, int, int *);
 void mppi(int *);
-void mppwr(int *, int, int *);
+void mppwr(const int *, int, int *);
 void mppwr2(int *, int *, int *);
 void mpset(int *, int *, int *);
 void mpsin(int *, int *);
 void mpsinh(int *, int *);
 void mpsqrt(int *, int *);
-void mpsub(int *, int *, int *);
 void mptanh(int *, int *);
 
 #endif /* MP_H */
Index: mpmath.c
===================================================================
--- mpmath.c	(revision 2167)
+++ mpmath.c	(working copy)
@@ -58,7 +58,7 @@
 
 
 void
-calc_and(int t[MP_SIZE], int s1[MP_SIZE], int s2[MP_SIZE])
+calc_and(const int s1[MP_SIZE], const int s2[MP_SIZE], int t[MP_SIZE])
 {
     double dres, dval;
 
@@ -70,7 +70,7 @@
 
 
 void
-calc_or(int t[MP_SIZE], int s1[MP_SIZE], int s2[MP_SIZE])
+calc_or(const int s1[MP_SIZE], const int s2[MP_SIZE], int t[MP_SIZE])
 {
     double dres, dval;
 
@@ -82,7 +82,7 @@
 
 
 void
-calc_xor(int t[MP_SIZE], int s1[MP_SIZE], int s2[MP_SIZE])
+calc_xor(const int s1[MP_SIZE], const int s2[MP_SIZE], int t[MP_SIZE])
 {
     double dres, dval;
 
@@ -94,7 +94,7 @@
 
 
 void
-calc_xnor(int t[MP_SIZE], int s1[MP_SIZE], int s2[MP_SIZE])
+calc_xnor(const int s1[MP_SIZE], const int s2[MP_SIZE], int t[MP_SIZE])
 {
     double dres, dval;
 
@@ -106,7 +106,7 @@
 
 
 void
-calc_not(int s1[MP_SIZE], int t[MP_SIZE])
+calc_not(const int s1[MP_SIZE], int t[MP_SIZE])
 {
     double dval = mp_cast_to_double(s1);
     
@@ -123,7 +123,7 @@
 
 
 void
-calc_u32(int s1[MP_SIZE], int t1[MP_SIZE])
+calc_u32(const int s1[MP_SIZE], int t1[MP_SIZE])
 {
     double dval = mp_cast_to_double(s1);
     dval = setbool(ibool(dval));
@@ -132,7 +132,7 @@
 
 
 void
-calc_u16(int s1[MP_SIZE], int t1[MP_SIZE])
+calc_u16(const int s1[MP_SIZE], int t1[MP_SIZE])
 {
     double dval = mp_cast_to_double(s1);
     dval = setbool(ibool(dval) & 0xffff);
@@ -141,7 +141,7 @@
 
 
 void
-calc_inv(int s1[MP_SIZE], int t1[MP_SIZE])     /* Calculate 1/x */
+calc_inv(const int s1[MP_SIZE], int t1[MP_SIZE])     /* Calculate 1/x */
 {
     int MP1[MP_SIZE];
     int MP2[MP_SIZE];
@@ -213,13 +213,13 @@
     mpdiv(op1, op2, MP1);
     mpcmim(MP1, MP1);
     mpmul(MP1, op2, MP2);
-    mpsub(op1, MP2, result);
+    mp_subtract(op1, MP2, result);
 
     mp_set_from_integer(0, MP1);
     if ((mp_is_less_than(op2, MP1)
 	 && mp_is_greater_than(result, MP1)) ||
 	mp_is_less_than(result, MP1)) { 
-        mpadd(result, op2, result);
+        mp_add(result, op2, result);
     }
 
     return 0;
@@ -354,14 +354,14 @@
         mp_set_from_mp(MPpi, MPretval);
     } else { 
         mpmul(MPx, MPx, MP2);
-        mpsub(MP1, MP2, MP2);
+        mp_subtract(MP1, MP2, MP2);
         mpsqrt(MP2, MP2);
         mpdiv(MP2, MPx, MP2);
         mpatan(MP2, MPy);
         if (mp_is_greater_than(MPx, MP0)) {
             mp_set_from_mp(MPy, MPretval);
         } else {
-            mpadd(MPy, MPpi, MPretval);
+            mp_add(MPy, MPpi, MPretval);
         }
     }
 }
@@ -385,9 +385,9 @@
         mp_set_from_integer(0, MPretval);
     } else {
         mpmul(MPx, MPx, MP1);
-        mpaddi(MP1, -1, MP1);
+        mp_add_integer(MP1, -1, MP1);
         mpsqrt(MP1, MP1);
-        mpadd(MPx, MP1, MP1);
+        mp_add(MPx, MP1, MP1);
         mpln(MP1, MPretval);
     }
 }
@@ -404,9 +404,9 @@
     int MP1[MP_SIZE];
  
     mpmul(MPx, MPx, MP1);
-    mpaddi(MP1, 1, MP1);
+    mp_add_integer(MP1, 1, MP1);
     mpsqrt(MP1, MP1);
-    mpadd(MPx, MP1, MP1);
+    mp_add(MPx, MP1, MP1);
     mpln(MP1, MPretval);
 }
 
@@ -432,8 +432,8 @@
         doerr(_("Error"));
         mp_set_from_mp(MP0, MPretval);
     } else {
-        mpadd(MP1, MPx, MP2);
-        mpsub(MP1, MPx, MP3);
+        mp_add(MP1, MPx, MP2);
+        mp_subtract(MP1, MPx, MP3);
         mpdiv(MP2, MP3, MP3);
         mpln(MP3, MP3);
         MPstr_to_num("0.5", DEC, MP1);
@@ -474,7 +474,7 @@
 
     mpdiv(v->MPmvals[1], v->MPmvals[2], MP1);
     mpln(MP1, MP2);
-    mpaddi(v->MPmvals[0], 1, MP3);
+    mp_add_integer(v->MPmvals[0], 1, MP3);
     mpln(MP3, MP4);
     mpdiv(MP2, MP4, t);
 }
@@ -505,11 +505,11 @@
     mp_set_from_integer(0, MPbv);
     len = mp_cast_to_int(v->MPmvals[3]);
     for (i = 0; i < len; i++) {
-        mpsub(v->MPmvals[0], MPbv, MP1);
+        mp_subtract(v->MPmvals[0], MPbv, MP1);
         mpmuli(MP1, 2, MP2);
         mpdiv(MP2, v->MPmvals[2], t);
         mp_set_from_mp(MPbv, MP1);
-        mpadd(MP1, t, MPbv); /* TODO: why result is MPbv, for next loop? */
+        mp_add(MP1, t, MPbv); /* TODO: why result is MPbv, for next loop? */
     }
 }
 
@@ -527,9 +527,9 @@
 
     int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE];
   
-    mpaddi(v->MPmvals[1], 1, MP1);
+    mp_add_integer(v->MPmvals[1], 1, MP1);
     mppwr2(MP1, v->MPmvals[2], MP2);
-    mpaddi(MP2, -1, MP3);
+    mp_add_integer(MP2, -1, MP3);
     mpmul(v->MPmvals[0], MP3, MP4);
     mpdiv(MP4, v->MPmvals[1], t);
 }
@@ -548,11 +548,11 @@
 
     int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE];
 
-    mpaddi(v->MPmvals[1], 1, MP1);
+    mp_add_integer(v->MPmvals[1], 1, MP1);
     mpmuli(v->MPmvals[2], -1, MP2);
     mppwr2(MP1, MP2, MP3);
     mpmuli(MP3, -1, MP4);
-    mpaddi(MP4, 1, MP1);
+    mp_add_integer(MP4, 1, MP1);
     mpdiv(v->MPmvals[1], MP1, MP2);
     mpmul(v->MPmvals[0], MP2, t);
 }
@@ -571,11 +571,11 @@
 
     int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE];
 
-    mpaddi(v->MPmvals[1], 1, MP1);
+    mp_add_integer(v->MPmvals[1], 1, MP1);
     mpmuli(v->MPmvals[2], -1, MP2);
     mppwr2(MP1, MP2, MP3);
     mpmuli(MP3, -1, MP4);
-    mpaddi(MP4, 1, MP1);
+    mp_add_integer(MP4, 1, MP1);
     mpdiv(MP1, v->MPmvals[1], MP2);
     mpmul(v->MPmvals[0], MP2, t);
 }
@@ -598,7 +598,7 @@
     mp_set_from_integer(1, MP2);
     mpdiv(MP2, v->MPmvals[2], MP3);
     mppwr2(MP1, MP3, MP4);
-    mpaddi(MP4, -1, t);
+    mp_add_integer(MP4, -1, t);
 }
 
 
@@ -615,7 +615,7 @@
   
     int MP1[MP_SIZE];
 
-    mpsub(v->MPmvals[0], v->MPmvals[1], MP1);
+    mp_subtract(v->MPmvals[0], v->MPmvals[1], MP1);
     mpdiv(MP1, v->MPmvals[2], t);
 }
 
@@ -635,14 +635,14 @@
 
     int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE];
 
-    mpsub(v->MPmvals[2], v->MPmvals[3], MP2);
-    mpaddi(MP2, 1, MP3);
-    mpaddi(v->MPmvals[2], 1, MP2);
+    mp_subtract(v->MPmvals[2], v->MPmvals[3], MP2);
+    mp_add_integer(MP2, 1, MP3);
+    mp_add_integer(v->MPmvals[2], 1, MP2);
     mpmul(v->MPmvals[2], MP2, MP4);
     mp_set_from_integer(2, MP2);
     mpdiv(MP4, MP2, MP1);
     mpdiv(MP3, MP1, MP2);
-    mpsub(v->MPmvals[0], v->MPmvals[1], MP1);
+    mp_subtract(v->MPmvals[0], v->MPmvals[1], MP1);
     mpmul(MP1, MP2, t);
 }
 
@@ -660,11 +660,11 @@
 
     int MP1[MP_SIZE], MP2[MP_SIZE], MP3[MP_SIZE], MP4[MP_SIZE];
 
-    mpaddi(v->MPmvals[2], 1, MP1);
+    mp_add_integer(v->MPmvals[2], 1, MP1);
     mpln(MP1, MP2);
     mpmul(v->MPmvals[1], v->MPmvals[2], MP1);
     mpdiv(MP1, v->MPmvals[0], MP3);
-    mpaddi(MP3, 1, MP4);
+    mp_add_integer(MP3, 1, MP4);
     mpln(MP4, MP1);
     mpdiv(MP1, MP2, t);
 }
@@ -833,7 +833,7 @@
     SNPRINTF(half, MAXLINE, "0.5");
     MPstr_to_num(half, DEC, MP2);
     mpdiv(MP2, MP1, MP1);
-    mpadd(MPval, MP1, MPval);
+    mp_add(MPval, MP1, MPval);
 
     mp_set_from_integer(1, MP2);
     if (mp_is_less_than(MPval, MP2)) {
@@ -862,7 +862,7 @@
 
         *optr++ = digits[dval];
         dval = -dval;
-        mpaddi(MPval, dval, MPval);
+        mp_add_integer(MPval, dval, MPval);
     }    
     *optr++ = '\0';
 
@@ -955,7 +955,7 @@
  
     SNPRINTF(half, MAXLINE, "0.5");
     MPstr_to_num(half, DEC, MP1);
-    mpaddi(MP1, exp, MPval);
+    mp_add_integer(MP1, exp, MPval);
     mp_set_from_integer(1, MP1);
     for (ddig = 0; mp_is_greater_equal(MPval, MP1); ddig++) {
         mpdiv(MPval, MP1base, MPval);
@@ -970,7 +970,7 @@
         dval = mp_cast_to_int(MPval);
         *optr++ = digits[dval];
         dval = -dval;
-        mpaddi(MPval, dval, MPval);
+        mp_add_integer(MPval, dval, MPval);
     }
     *optr++    = '\0';
 }
@@ -1054,7 +1054,7 @@
 
     while ((inum = char_val(*optr)) >= 0) {
         mpmul(MPval, MPbase, MPval);
-        mpaddi(MPval, inum, MPval);
+        mp_add_integer(MPval, inum, MPval);
         optr++;
     }
 
@@ -1064,7 +1064,7 @@
             mppwr(MPbase, i, MP1);
             mp_set_from_integer(inum, MP2);
             mpdiv(MP2, MP1, MP1);
-            mpadd(MPval, MP1, MPval);
+            mp_add(MPval, MP1, MPval);
         optr++;
         }
     }
@@ -1091,7 +1091,7 @@
 
 
 void
-mp_set_from_string(char *number, int t[MP_SIZE])
+mp_set_from_string(const char *number, int t[MP_SIZE])
 {
     int i;
     char *a = NULL;
Index: ce_parser.y
===================================================================
--- ce_parser.y	(revision 2167)
+++ ce_parser.y	(working copy)
@@ -147,8 +147,8 @@
 exp: 
   term {cp($1, $$);}
 
-| exp '+' exp {mpadd($1, $3, $$);}
-| exp '-' exp {mpsub($1, $3, $$);}
+| exp '+' exp {mp_add($1, $3, $$);}
+| exp '-' exp {mp_subtract($1, $3, $$);}
 
 | exp tMOD exp %prec MED {
     if (!is_integer($1) || !is_integer($3)) {
@@ -164,25 +164,25 @@
     if (!is_natural($1) || !is_natural($3)) {
 	parser_state.error = -PARSER_ERR_BITWISEOP;
     }
-    calc_and($$, $1, $3);
+    calc_and($1, $3, $$);
 }
 | exp tOR exp {
     if (!is_natural($1) || !is_natural($3)) {
 	parser_state.error = -PARSER_ERR_BITWISEOP;
     }
-    calc_or($$, $1, $3);
+    calc_or($1, $3, $$);
 }
 | exp tXNOR exp {
     if (!is_natural($1) || !is_natural($3)) {
 	parser_state.error = -PARSER_ERR_BITWISEOP;
     }
-    calc_xnor($$, $1, $3);
+    calc_xnor($1, $3, $$);
 }
 | exp tXOR exp {
     if (!is_natural($1) || !is_natural($3)) {
 	parser_state.error = -PARSER_ERR_BITWISEOP;
     }
-    calc_xor($$, $1, $3);
+    calc_xor($1, $3, $$);
 }
 | '~' exp {
     if (!is_natural($2)) {
Index: mpmath.h
===================================================================
--- mpmath.h	(revision 2167)
+++ mpmath.h	(working copy)
@@ -39,19 +39,18 @@
 int calc_trigfunc(enum trigfunc_type type, int s1[MP_SIZE], int t1[MP_SIZE]);
 
 void mplogn(int n, int *MPx, int *MPretval);
-void calc_and(int t[MP_SIZE], int s1[MP_SIZE], int s2[MP_SIZE]);
-void calc_or(int t[MP_SIZE], int s1[MP_SIZE], int s2[MP_SIZE]);
-void calc_xor(int t[MP_SIZE], int s1[MP_SIZE], int s2[MP_SIZE]);
-void calc_xnor(int t[MP_SIZE], int s1[MP_SIZE], int s2[MP_SIZE]);
-void calc_not(int t[MP_SIZE], int s1[MP_SIZE]);
+void calc_and(const int s1[MP_SIZE], const int s2[MP_SIZE], int t[MP_SIZE]);
+void calc_or(const int s1[MP_SIZE], const int s2[MP_SIZE], int t[MP_SIZE]);
+void calc_xor(const int s1[MP_SIZE], const int s2[MP_SIZE], int t[MP_SIZE]);
+void calc_xnor(const int s1[MP_SIZE], const int s2[MP_SIZE], int t[MP_SIZE]);
+void calc_not(const int s1[MP_SIZE], int t[MP_SIZE]);
 void calc_rand(int t[MP_SIZE]);
-void calc_u32(int s1[MP_SIZE], int t1[MP_SIZE]);
-void calc_u16(int s1[MP_SIZE], int t1[MP_SIZE]);
+void calc_u32(const int s1[MP_SIZE], int t1[MP_SIZE]);
+void calc_u16(const int s1[MP_SIZE], int t1[MP_SIZE]);
 void calc_percent(int s1[MP_SIZE], int t1[MP_SIZE]);
-void calc_inv(int s1[MP_SIZE], int t1[MP_SIZE]);
+void calc_inv(const int s1[MP_SIZE], int t1[MP_SIZE]);
 void calc_tenpowx(int s1[MP_SIZE], int t1[MP_SIZE]);
 void calc_xpowy(int MPx[MP_SIZE], int MPy[MP_SIZE], int MPres[MP_SIZE]);
-void do_zero(int t1[MP_SIZE]);
 void do_e(int t1[MP_SIZE]);
 void calc_xtimestenpowx(int s1[MP_SIZE], int s2[MP_SIZE], int t1[MP_SIZE]);
 int calc_modulus(int op1[MP_SIZE], int op2[MP_SIZE], int result[MP_SIZE]);
@@ -80,7 +79,7 @@
 
 // FIXME: These should be merged together
 void MPstr_to_num(const char *, enum base_type, int *);
-void mp_set_from_string(char *number, int t[MP_SIZE]);
+void mp_set_from_string(const char *number, int t[MP_SIZE]);
 void make_fixed(char *, int, int *, int, int, int);
 void make_number(char *, int, int *, int, int);
 
Index: unittest.c
===================================================================
--- unittest.c	(revision 2167)
+++ unittest.c	(working copy)
@@ -70,7 +70,15 @@
 
     test("0+0", "0", 0);
     test("1+1", "2", 0);
+    test("1+4", "5", 0);
+    test("4+1", "5", 0);
+    test("40000+0.001", "40000.001", 0);
+    test("0.001+40000", "40000.001", 0);
     test("2-3", "-1", 0);
+    test("3-2", "1", 0);
+    test("40000-0.001", "39999.999", 0);
+    test("0.001-40000", "-39999.999", 0);
+    test("40000000-40000000", "0", 0);
     test("2*3", "6", 0);
     //FIXME: Need to update mperr() test("1/2", "0.5", 0);
     //FIXME: Need to update mperr() test("1/0", "", 0);
@@ -115,6 +123,12 @@
     
     v->ttype = GRAD;
     test("Sin(100)", "1", 0);
+
+    test("3 And 5", "1", 0);
+    test("3 Or 5", "7", 0);
+    test("3 Xor 5", "6", 0);
+    test("3 Xnor 5", "4294967289", 0);
+    test("~ 122", "4294967173", 0);
 }
 
 
