harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r566500 - in /harmony/enhanced/classlib/trunk/modules/math/src: main/java/java/math/BigDecimal.java test/java/tests/api/java/math/BigDecimalTest.java
Date Thu, 16 Aug 2007 06:40:27 GMT
Author: pyang
Date: Wed Aug 15 23:40:26 2007
New Revision: 566500

URL: http://svn.apache.org/viewvc?view=rev&rev=566500
Log:
fix HARMONY-4623( BigDecimal.stripTrailingZero fails for 0.0000)

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=566500&r1=566499&r2=566500
==============================================================================
--- 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 Wed
Aug 15 23:40:26 2007
@@ -1314,7 +1314,7 @@
         long newScale = scale;
 
         if (isZero()) {
-            return this;
+            return new BigDecimal("0");
         }
         BigInteger strippedBI = getUnscaledValue();
         BigInteger[] quotAndRem;

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=566500&r1=566499&r2=566500
==============================================================================
--- 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
Wed Aug 15 23:40:26 2007
@@ -894,4 +894,26 @@
         assertEquals(bd.doubleValue(), nbd.doubleValue(), 0.0);
         assertEquals(bd.toString(), nbd.toString());
     }
+	
+	/**
+	 * @tests java.math.BigDecimal#stripTrailingZero(long)
+	 */
+	public void test_stripTrailingZero() {
+		BigDecimal sixhundredtest = new BigDecimal("600.0");
+		assertTrue("stripTrailingZero failed for 600.0",
+				((sixhundredtest.stripTrailingZeros()).scale() == -2)
+				);
+		
+		/* Single digit, no trailing zero, odd number */
+		BigDecimal notrailingzerotest = new BigDecimal("1");
+		assertTrue("stripTrailingZero failed for 1",
+				((notrailingzerotest.stripTrailingZeros()).scale() == 0)
+				);
+		
+		/* Zero */
+		BigDecimal zerotest = new BigDecimal("0.0000");
+		assertTrue("stripTrailingZero failed for 0.0000",
+				((zerotest.stripTrailingZeros()).scale() == 0)
+				);		
+	}	
 }



Mime
View raw message