Hi Paulex, This looks to me to be a bug in the RI. I think the spec is clear on what the returned BigDecimal representation should be. If we follow the guidelines at [1], then I would say that we should follow the spec in this case until we find a reason to go with the RI version (like an app. that relies on this result, although I cannot imagine that happening).
Do you agree? Regards, Oliver [1] http://harmony.apache.org/subcomponents/classlibrary/compat.html On 8/15/07, Yang Paulex <[EMAIL PROTECTED]> wrote: > > 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 >
