harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yang Paulex" <paulex.y...@gmail.com>
Subject [classlib][math]Non-bug difference? (was Re: [jira] Created: (HARMONY-4623) BigDecimal.stripTrailingZero fails for 0.0000)
Date Wed, 15 Aug 2007 03:56:14 GMT
Hi, all,

I'm looking at this issue, the spec on BigDecimal.stripTrialingZeros()
mentioned:

"Returns a BigDecimal which is numerically equal to this one but with any
trailing zeros removed from the representation. For example, stripping the
trailing zeros from the BigDecimal value 600.0, which has [BigInteger, scale]
components equals to [6000, 1], yields 6E2 with [BigInteger, scale]
components equals to [6, -2]"

While seems new BigDecimal("0.0000").stripTrialingZeros() just return this
without any changes, IMHO this is contradict with spec. Currently Harmony
has same behavior, should we follow RI or spec here?

A quick and naive fix would be:

--- main/java/java/math/BigDecimal.java (修订版 566012)
+++ main/java/java/math/BigDecimal.java (工作拷贝)
@@ -1314,7 +1314,7 @@
         long newScale = scale;

         if (isZero()) {
-            return this;
+            return new BigDecimal("0");
         }

2007/8/14, Imran Ghory (JIRA) <jira@apache.org>:
>
> BigDecimal.stripTrailingZero fails for 0.0000
> ---------------------------------------------
>
>                  Key: HARMONY-4623
>                  URL: https://issues.apache.org/jira/browse/HARMONY-4623
>              Project: Harmony
>           Issue Type: Bug
>           Components: Classlib
>             Reporter: Imran Ghory
>             Priority: Minor
>
>
> BigDecimal.stripTrailingZero fails for "0.0000" (leaves it unstriped).
> This behaviour occurs in the RI as well, however from the specification it
> seems this behaviour is incorrect. Will attach test case.
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>


-- 
Paulex Yang
China Software Development laboratory
IBM
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message