harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r502189 - in /harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math: BigDecimal.java BigInteger.java
Date Thu, 01 Feb 2007 10:52:30 GMT
Author: apetrenko
Date: Thu Feb  1 02:52:29 2007
New Revision: 502189

URL: http://svn.apache.org/viewvc?view=rev&rev=502189
Log:
Patch for HARMONY-3088 "[math]java.math.BigDecimal/java.math.BigInteger.equals improvement"

Modified:
    harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigDecimal.java
    harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigInteger.java

Modified: harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigDecimal.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigDecimal.java?view=diff&rev=502189&r1=502188&r2=502189
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigDecimal.java (original)
+++ harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigDecimal.java Thu
Feb  1 02:52:29 2007
@@ -1375,15 +1375,20 @@
 
     /** @ar.org.fitc.spec_ref */
     @Override
-    public boolean equals(Object x) {
-        return ((x instanceof BigDecimal)
-        && (((BigDecimal)x).scale == scale)
-        && (((BigDecimal)x).bitLength == bitLength)
-        && (bitLength < 64 ?
-            (((BigDecimal)x).smallValue == smallValue)
-            : (((BigDecimal)x).getUnscaledValue().equals(getUnscaledValue())))
-            );
-    }
+    public boolean equals(Object x) {    	
+    	if (this == x) {
+    		return true;
+    	}
+    	if (x instanceof BigDecimal) {
+    	    BigDecimal x1 = (BigDecimal) x;    	    
+    	    return x1.scale == scale                   
+                   && (bitLength < 64 ? (x1.smallValue == smallValue)
+                    : intVal.equals(x1.intVal));
+                	    
+    	     
+    	} 
+    	return false;       
+    }   
 
     /** @ar.org.fitc.spec_ref */
     public BigDecimal min(BigDecimal val) {

Modified: harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigInteger.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigInteger.java?view=diff&rev=502189&r1=502188&r2=502189
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigInteger.java (original)
+++ harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigInteger.java Thu
Feb  1 02:52:29 2007
@@ -612,7 +612,24 @@
     /** @ar.org.fitc.spec_ref */
     @Override
     public boolean equals(Object x) {
-        return ((x instanceof BigInteger) && (compareTo((BigInteger) x) == EQUALS));
+    	if (this == x) {
+		    return true;
+	    }
+	    if (x instanceof BigInteger) {
+		    BigInteger x1 = (BigInteger)x;            
+            return sign == x1.sign 
+                   && numberLength == x1.numberLength 
+                   && equalsArrays(x1.digits);    		
+	    }
+        return false;
+    } 
+
+    boolean equalsArrays(final int[] b) {
+        int i;        
+        for (i = numberLength - 1; (i >= 0) && (digits[i] == b[i]); i--) {
+            ;
+        }        
+        return i < 0;
     }
 
     /** @ar.org.fitc.spec_ref */



Mime
View raw message