This is the mail archive of the java-patches@gcc.gnu.org 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]

Another BigInteger bug.


Right shifts of negative numbers by nonzero multiples of 32 generally
produced the wrong answer.  This seems to be yet another case where the code
assumed that left shifting an int by 32 produced 0.

OK to commit to the trunk?

Hans

	* BigInteger.java: fix right shifts by nonzero multiples of 32.

Index: BigInteger.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/math/BigInteger.java,v
retrieving revision 1.12
diff -u -r1.12 BigInteger.java
--- BigInteger.java	2001/06/19 11:42:03	1.12
+++ BigInteger.java	2001/08/16 22:58:19
@@ -1397,7 +1397,7 @@
 	      realloc(d_len);
 	    MPN.rshift0 (words, x.words, word_count, d_len, count);
 	    ival = d_len;
-	    if (neg)
+	    if (neg && count != 0)
 	      words[d_len-1] |= -1 << (32 - count);
 	  }
       }


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