]> Cypherpunks repositories - gostls13.git/commitdiff
bug 113
authorKen Thompson <ken@golang.org>
Wed, 29 Oct 2008 23:38:23 +0000 (16:38 -0700)
committerKen Thompson <ken@golang.org>
Wed, 29 Oct 2008 23:38:23 +0000 (16:38 -0700)
R=r
OCL=18077
CL=18077

src/cmd/gc/mparith2.c

index d50aad7b2ab868570fe267920f15a273c482d5c5..591501140e26ae6b3104e0343a1984c75a8f31e1 100644 (file)
@@ -149,12 +149,13 @@ mpneg(Mpint *a)
        a1 = &a->a[0];
        c = 0;
        for(i=0; i<Mpprec; i++) {
-               x = c - *a1;
-               *a1++ = x;
-
+               x = -*a1 -c;
                c = 0;
-               if(x < 0)
+               if(x < 0) {
+                       x += Mpbase;
                        c = 1;
+               }
+               *a1++ = x;
        }
 }
 
@@ -295,8 +296,8 @@ mporfixfix(Mpint *a, Mpint *b)
        a1 = &a->a[0];
        b1 = &b->a[0];
        for(i=0; i<Mpprec; i++) {
-               x = *a1;
-               *a1++ = x | *b1++;
+               x = *a1 | *b1++;
+               *a1++ = x;
        }
 
        if(b->neg)
@@ -329,8 +330,8 @@ mpandfixfix(Mpint *a, Mpint *b)
        a1 = &a->a[0];
        b1 = &b->a[0];
        for(i=0; i<Mpprec; i++) {
-               x = *a1;
-               *a1++ = x & *b1++;
+               x = *a1 & *b1++;
+               *a1++ = x;
        }
 
        if(b->neg)
@@ -363,8 +364,8 @@ mpxorfixfix(Mpint *a, Mpint *b)
        a1 = &a->a[0];
        b1 = &b->a[0];
        for(i=0; i<Mpprec; i++) {
-               x = *a1;
-               *a1++ = x ^ *b1++;
+               x = *a1 ^ *b1++;
+               *a1++ = x;
        }
 
        if(b->neg)