Java 8 RFR 6480539: BigDecimal.stripTrailingZeros() has no effect on zero itself ("0.0")

Joe Darcy joe.darcy at oracle.com
Wed Jul 3 18:40:03 UTC 2013


On 07/03/2013 11:09 AM, Brian Burkhalter wrote:
> On Jul 3, 2013, at 10:47 AM, Brian Burkhalter wrote:
>
>> I'll update this only to change the one public method and to modify its specification.
> I've updated the webrev
>
> http://cr.openjdk.java.net/~bpb/6480539/
>
> and rerun JTREG as well as modifying and resubmitting the CCC request (it had been filed for the previous fix proposal).
>

The compareMagnitude method is private so shouldn't be used in the 
behavioral description. I recommend something like, "If this {@code 
BigDecimal} is numerically equal to zero, {@code BigDecimal.ZERO} is 
returned."

Also, in the initial check, instead of

2604         if (compareMagnitude(BigDecimal.ZERO) == 0) {
2605             return BigDecimal.ZERO;
2606         } else if (intCompact != INFLATED) {

something like

     if (intCompact == 0 or intVal.signum() == 0)

might be faster.

Also, I recommend adding a few more test cases for zeros with small 
exponents, e.g. "0e2", "0e-2".

thanks,

-Joe




More information about the core-libs-dev mailing list