harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r504176 - in /harmony/enhanced/classlib/trunk/modules/math/src: main/java/java/math/BigDecimal.java test/java/tests/api/java/math/BigDecimalTest.java
Date Tue, 06 Feb 2007 15:18:32 GMT
Author: ayza
Date: Tue Feb  6 07:18:31 2007
New Revision: 504176

URL: http://svn.apache.org/viewvc?view=rev&rev=504176
Log:
Applying patch from HARMONY-2429 ([classlib][math] java.math.BigDecimal(-0.0) returns wrong
object)

Modified:
    harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigDecimal.java
    harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.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=504176&r1=504175&r2=504176
==============================================================================
--- 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 Tue
Feb  6 07:18:31 2007
@@ -363,6 +363,10 @@
         // Extracting the 52 bits of the mantisa.
         mantisa = (scale == 1075) ? (bits & 0xFFFFFFFFFFFFFL) << 1
                 : (bits & 0xFFFFFFFFFFFFFL) | 0x10000000000000L;
+        if (mantisa == 0) {
+            scale = 0;
+            precision = 1;
+        }
         // To simplify all factors '2' in the mantisa 
         if (scale > 0) {
             trailingZeros = Math.min(scale, Long.numberOfTrailingZeros(mantisa));

Modified: harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java?view=diff&rev=504176&r1=504175&r2=504176
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/math/src/test/java/tests/api/java/math/BigDecimalTest.java
Tue Feb  6 07:18:31 2007
@@ -78,7 +78,11 @@
 		assertTrue(
 				"the double representation of 0.00345 bigDecimal is not correct",
 				big.doubleValue() == 0.00345);
-
+        // regression test for HARMONY-2429
+        big = new BigDecimal(-0.0);
+        assertTrue(
+        		"the double representation of -0.0 bigDecimal is not correct",
+        		big.scale() == 0);
 	}
 
 	/**



Mime
View raw message