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) <[EMAIL PROTECTED]>:
>
> 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