RFR: 8251989: Hex formatting and parsing utility [v17]

Joe Darcy darcy at openjdk.java.net
Tue Dec 8 03:24:20 UTC 2020


On Fri, 4 Dec 2020 22:13:21 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> src/java.base/share/classes/java/util/HexFormat.java line 936:
>> 
>>> 934:      *      if any of the characters is not a hexadecimal character
>>> 935:      */
>>> 936:     public int fromHexDigits(CharSequence string) {
>> 
>> I recommend this group of methods include an apinote explaining the differences in behavior of compared to parseInt(s, 16) and parseUnsignedInt(s, 16).
>
> Will add:
>      * @apiNote
>      * {@link Integer#parseInt(String, int) Integer.parseInt(s, 16)} and
>      * {@link Integer#parseUnsignedInt(String, int) Integer.pareUnsignedInt(s, 16)}
>      * are similar but allow all Unicode hexadecimal digits allowed by
>      * {@link Character#digit(char, int) Character.digit(ch, 16)}.
>      * {@code HexFormat} uses only Latin1 hexadecimal characters "0-9, "A-F", and "a-f".
>      * {@link Integer#parseInt(String, int)} can parse signed hexadecimal strings.
> And similar text for Long#parseLong and Long.parseUnsignedLong

Okay; however, I suggest saying more on the signed/unsigned behavior.

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

PR: https://git.openjdk.java.net/jdk/pull/482


More information about the core-libs-dev mailing list