Patch: java.math.BigInteger.signum

Warren Levy warrenl@cygnus.com
Wed Mar 8 20:34:00 GMT 2000


Folks,
I'm committing this libgcj patch for a problem that Hans Boehm reported
the other day.
--warrenl


2000-03-08  Warren Levy  <warrenl@cygnus.com>

        * java/math/BigInteger.java(signum): Handle zero properly.


Index: java/math/BigInteger.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/math/BigInteger.java,v
retrieving revision 1.5
diff -u -p -r1.5 BigInteger.java
--- BigInteger.java	2000/03/07 19:55:27	1.5
+++ BigInteger.java	2000/03/09 04:32:08
@@ -285,7 +285,9 @@ public class BigInteger extends Number i
   public int signum()
   {
     int top = words == null ? ival : words[ival-1];
-    return top > 0 ? 1 : top < 0 ? -1 : 0;
+    if (top == 0 && words == null)
+      return 0;
+    return top < 0 ? -1 : 1;
   }
 
   private static int compareTo(BigInteger x, BigInteger y)





More information about the Java-patches mailing list