[freenet-devl] Re: Yet another GCJ update. (a/k/a PR 1615 followup)

Per Bothner per@bothner.com
Fri Feb 23 21:08:00 GMT 2001


"Mark J. Roberts" <mjr@statesmean.com> writes:
> This patch fixes a situation where BigInteger.divide generates bogus
> remainders and quotients for certain input. I posted a test case for this,
> you can see it at http://gcc.gnu.org/ml/java/2001-02/msg00293.html . This
> patch fixes that bug:

Well, the strange thing is that when I do the division in Kawa (using
gnu.math), I get the correct result. But while doing some experiments,
comparing the the gnu.math.IntNum and BigInteger source I noticed that
the latter was missing the following code:
Index: BigInteger.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/math/BigInteger.java,v
retrieving revision 1.10
diff -u -r1.10 BigInteger.java
--- BigInteger.java	2001年01月17日 04:13:17	1.10
+++ BigInteger.java	2001年02月24日 04:58:38
@@ -810,6 +810,12 @@
 	 }
 }
 
+ if (ywords[rlen-1] < 0)
+ {
+ ywords[rlen] = 0;
+ rlen++;
+ }
+
 // Now the quotient is in xwords, and the remainder is in ywords.
 
 boolean add_one = false;
I also now noticed a ChangeLog entry which I had managed to overlook
previously - probably because because it was staring right at me at
the top of the ChangeLog!
2000年09月21日 Per Bothner <per@bothner.com>
	* IntNum.java (divide): Zero-extend results if high-order bit set.
So I believe your patch is basically correct. However, I think it should
be done before the "add_one" calculation, as in my patch. Sorry for
not noticing this change earlier - and for that matter, not submitting
the change when I fixed the gnu.math version.
-- 
	--Per Bothner
per@bothner.com http://www.bothner.com/~per/


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /