harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r1001723 - in /harmony/enhanced/java/trunk/classlib/modules/math/src: main/java/java/math/BigDecimal.java test/java/org/apache/harmony/tests/java/math/BigDecimalCompareTest.java
Date Mon, 27 Sep 2010 13:06:57 GMT
Author: tellison
Date: Mon Sep 27 13:06:57 2010
New Revision: 1001723

URL: http://svn.apache.org/viewvc?rev=1001723&view=rev
Log:
Apply fix for HARMONY-6406 (Combination of multiply and compareTo BigDecimal methods returns
unexpected result)

Modified:
    harmony/enhanced/java/trunk/classlib/modules/math/src/main/java/java/math/BigDecimal.java
    harmony/enhanced/java/trunk/classlib/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalCompareTest.java

Modified: harmony/enhanced/java/trunk/classlib/modules/math/src/main/java/java/math/BigDecimal.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/math/src/main/java/java/math/BigDecimal.java?rev=1001723&r1=1001722&r2=1001723&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/math/src/main/java/java/math/BigDecimal.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/math/src/main/java/java/math/BigDecimal.java
Mon Sep 27 13:06:57 2010
@@ -2940,9 +2940,8 @@ public class BigDecimal extends Number i
      * @return an approximation of {@code precision()} value
      */
     private int aproxPrecision() {
-        return ((precision > 0)
-        ? precision
-                : (int)((this.bitLength - 1) * LOG10_2)) + 1;
+        return (precision > 0) ? precision
+                : ((int) ((this.bitLength - 1) * LOG10_2)) + 1;
     }
 
     /**

Modified: harmony/enhanced/java/trunk/classlib/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalCompareTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalCompareTest.java?rev=1001723&r1=1001722&r2=1001723&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalCompareTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalCompareTest.java
Mon Sep 27 13:06:57 2010
@@ -500,4 +500,13 @@ public class BigDecimalCompareTest exten
        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
        assertEquals("incorrect value", 0, aNumber.signum());
     }
+    
+    /*
+     * Regression test for HARMONY-6406
+     */
+    public void testApproxPrecision() {
+        BigDecimal testInstance = BigDecimal.TEN.multiply(new BigDecimal("0.1"));
+        int result = testInstance.compareTo(new BigDecimal("1.00"));
+        assertEquals(0, result);
+    }
 }



Mime
View raw message