some minor improvements
authorceriel <none@none>
Thu, 19 Oct 1989 14:50:52 +0000 (14:50 +0000)
committerceriel <none@none>
Thu, 19 Oct 1989 14:50:52 +0000 (14:50 +0000)
modules/src/flt_arith/flt_ar2flt.c
modules/src/flt_arith/flt_chk.c
modules/src/flt_arith/flt_cmp.c
modules/src/flt_arith/flt_div.c
modules/src/flt_arith/flt_str2fl.c

index 2582a4b..ad1eaec 100644 (file)
@@ -16,20 +16,19 @@ flt_arith2flt(n, e)
        */
        register int i;
 
-       if (n == 0) {
-               e->flt_exp = 0;
-               e->flt_sign = 0;
-               e->m1 = e->m2 = 0;
-               return;
-       }
        if (n < 0) {
                e->flt_sign = 1;
                n = -n;
        }
        else    e->flt_sign = 0;
-       e->flt_exp = 63;
        e->m1 = e->m2 = 0;
+       if (n == 0) {
+               e->flt_exp = 0;
+               return;
+       }
+       e->flt_exp = 63;
        if (n < 0) {
+               /* n = MINARITH */
                n = 0x40000000;
                while ((n << 1) > 0) n <<= 1;
                e->flt_exp++;
index 1ec3a16..e7ddcab 100644 (file)
@@ -16,13 +16,12 @@ flt_chk(e)
                flt_status = FLT_OVFL;
                e->flt_exp = EXT_MAX;
                e->m1 = 0x80000000;
-               e->m2 = 0;
        }
        if (e->flt_exp <= EXT_MIN) {
                flt_status = FLT_UNFL;
                e->flt_exp = 0;
                e->m1 = 0;
-               e->m2 = 0;
                e->flt_sign = 0;
        }
+       e->m2 = 0;
 }
index 847c898..b78707d 100644 (file)
@@ -14,8 +14,8 @@ flt_cmp(e1, e2)
        int sign;
        int tmp;
 
-       if (e1->flt_exp == 0 && e1->m1 == 0 && e1->m2 == 0 &&
-           e2->flt_exp == 0 && e2->m1 == 0 && e2->m2 == 0) {
+       if (e1->m1 == 0 && e1->m2 == 0 &&
+           e2->m1 == 0 && e2->m2 == 0) {
                return 0;
        }
        sign = e1->flt_sign ? -1 : 1;
index 35e3105..4e29870 100644 (file)
@@ -51,6 +51,7 @@ flt_div(e1,e2,e3)
         */
        for (j = 0; j <= 3; j++, u_p++) {
                long q_est, temp;
+               long v1 = v[1];
 
                if (j == 2) lp++;
                if (u_p[0] == 0 && u_p[1] < v[1]) continue;
@@ -62,22 +63,22 @@ flt_div(e1,e2,e3)
                        q_est = temp;
                }
                else if (temp >= 0) {
-                       q_est = temp / (long)v[1];
+                       q_est = temp / v1;
                }
                else {
                        long rem;
-                       q_est = (0x7FFFFFFF/(long)v[1])+((temp&0x7FFFFFFF)/(long)v[1]);
-                       rem = (0x7FFFFFFF%(long)v[1])+((temp&0x7FFFFFFF)%(long)v[1])+1;
-                       while (rem > (long)v[1]) {
+                       q_est = (0x7FFFFFFF/v1)+((temp&0x7FFFFFFF)/v1);
+                       rem = (0x7FFFFFFF%v1)+((temp&0x7FFFFFFF)%v1)+1;
+                       while (rem > v1) {
                                q_est++;
-                               rem -= v[1];
+                               rem -= v1;
                        }
                }
-               temp -= q_est * (long)v[1];
+               temp -= q_est * v1;
                while (!(temp&0xFFFF0000) &&
                       ucmp((long)v[2]*q_est,(temp<<16)+(long)u_p[2]) > 0) {
                        q_est--;
-                       temp += v[1];
+                       temp += v1;
                }
                /*      Now, according to Knuth, we have an estimate of the
                        quotient, that is either correct or one too big, but
@@ -97,14 +98,14 @@ flt_div(e1,e2,e3)
                                k = (tmp >> 16) & 0xFFFF;
                        }
                        k += borrow;
-                       borrow = u_p[0] < k;
+                       borrow = (long)u_p[0] < k;
                        u_p[0] -= k;
 
                        if (borrow) {
                                /* So, this does not happen often; the estimate
                                   was one too big; correct this
                                */
-                               *lp |= (j & 1) ? (q_est - 1) : ((q_est-1)<<16);
+                               q_est--;
                                borrow = 0;
                                for (i = maxv; i > 0; i--) {
                                        long tmp 
@@ -115,7 +116,7 @@ flt_div(e1,e2,e3)
                                }
                                u_p[0] += borrow;
                        }
-                       else *lp |= (j & 1) ? q_est : (q_est<<16);
+                       *lp |= (j & 1) ? q_est : (q_est<<16);
                }
        }
        e3->m1 = result[0];
index e3d1fcd..f6431de 100644 (file)
@@ -208,8 +208,6 @@ add_exponent(e, exp)
        while (divsz >= BIGSZ) {
                flt_mul(&x, neg ? &r_big_10pow[BIGSZ-1] : &big_10pow[BIGSZ-1],&x);
                divsz -= BIGSZ-1;
-               flt_chk(e);
-               if (flt_status != 0) return;
        }
        flt_mul(&x, (neg ? r_big_10pow : big_10pow) + divsz, e);
 }