On Fri, 13 Oct 2023 17:01:11 GMT, Shaojin Wen <d...@openjdk.org> wrote:

>> I submitted PR #15555 before, and there were too many changes. I split it 
>> into multiple PRs with small changes. This one is one of them.
>> 
>> this PR removed the duplicate code for getChars in 
>> BigDecimal#StringBuilderHelper, i also make performance faster.
>> Please review and don't hesitate to critique my approach and patch.
>
> Shaojin Wen has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   use % calculate lowInt

src/java.base/share/classes/java/math/BigDecimal.java line 4162:

> 4160:             int highInt = (int)intCompact / 100;
> 4161:             short pair = DecimalDigits.digitPair((int)intCompact % 100);
> 4162:             return "" + highInt + '.' + (char)(pair & 0xff) + 
> (char)(pair >> 8);

FTR: while this works (since `pair` is never negative), casting `pair` to 
`char` or changing to `(char)((pair >> 8) & 0xff)` would be necessary for the 
general case.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16006#discussion_r1358751744

Reply via email to