On Fri, 18 Sep 2026 08:20:09 GMT, ExE Boss <[email protected]> wrote:

>> Justin Lu has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   Fix explanatory comment
>
> src/java.base/share/classes/java/text/CompactNumberFormat.java line 845:
> 
>> 843:             // Perform this division exactly, so that the quotient is 
>> not inaccurately rounded.
>> 844:             // For example, 22,550 / 1,000 should become 22.55 and not 
>> 22. It is safe to perform exact
>> 845:             // division because the divisor is a power of ten, thus the 
>> result is always terminating.
> 
> Since `.5` rounds toward the greater magnitude in common mathematical 
> rounding (aka. round half away from zero), the example should probably be one 
> which rounds the same in both common mathematical rounding and “round half to 
> even” rounding (which is used by **IEEE 754**)
> Suggestion:
> 
>             // Perform this division exactly, so that the quotient is not 
> inaccurately rounded.
>             // For example, 21,550 / 1,000 should become 21.55 and not 22. It 
> is safe to perform exact
>             // division because the divisor is a power of ten, thus the 
> result is always terminating.

Thanks for spotting this, you're right. I was tinkering with the example and 
must have forgotten to update the result, because it should have been `23`, not 
`22`. I updated it with an example that eliminates any of the HALF rounding 
ambiguity.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/32933#discussion_r4049279593

Reply via email to