This is the mail archive of the java-patches@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: BigInteger.modPow bug? (was: Freenet compilation errors.)


"Boehm, Hans" wrote:

> Here is a patch for the problem I was observing.  Unfortunately, that seems
> to be different from the mod problem reported below.

Thanks. I'm checking this in w/ Changelog entry and formatting fixes.

regards

  [ bryce ]

2001-01-16  Hans Boehm  <hans_boehm@hp.com>

 * java/math/BigInteger.java (setShiftRight): Only do negative shift
 if count != 0.

Index: java/math/BigInteger.java
===================================================================
RCS file: /cvs/gcc/egcs/libjava/java/math/BigInteger.java,v
retrieving revision 1.8
diff -u -r1.8 BigInteger.java
--- BigInteger.java     2000/10/27 10:33:46     1.8
+++ BigInteger.java     2001/01/17 00:58:40
@@ -1401,11 +1401,13 @@
              realloc(d_len);
            if (count == 0)
              System.arraycopy(x.words, word_count, words, 0, d_len);
-           else
-             MPN.rshift(words, x.words, word_count, d_len, count);
+            else
+             {
+               MPN.rshift(words, x.words, word_count, d_len, count);
+               if (neg)
+                 words[d_len-1] |= -1 << (32 - count);
+              }
            ival = d_len;
-           if (neg)
-             words[ival-1] |= -1 << (32 - count);
          }
       }
   }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]