On Wed, 8 Oct 2025 17:39:39 GMT, Naoto Sato <[email protected]> wrote:

>> test/jdk/java/text/Format/NumberFormat/NumberRegression.java line 1779:
>> 
>>> 1777:                 "0%", "0%", "1%", "1%", "1%",
>>> 1778:                 "0", "2", "0.2", "0.6", "0.04",
>>> 1779:                 "0.04", "0.001", "0.002",
>> 
>> This test is checking that `.0005` rounded to 3 digits is "0.000" under 
>> HALF_EVEN.
>> 
>> This is wrong. See,
>> `new BigDecimal(0.0005) ==> 
>> 0.0005000000000000000104083408558608425664715468883514404296875`. 
>> 
>> Resolving the bug in this PR requires fixing this incorrect test case. From 
>> the JDK-4241880 issue, it seems this case may have been put in to "document 
>> the incorrect but actual behavior".
>
> I guess this is the exact case this fix is trying to address, but the 
> expected result wrongly assumes the behavior.

Right. This code used to return "0.000" because `count` would erroneously not 
be `1` for this specific case, hence going down the "there are additional 
digits" path. For HALF_EVEN, this returns true if there are additional non-zero 
digits past the last index. As there are none because the String double is 
given as ".0005", it rounded down.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/27681#discussion_r2414634438

Reply via email to