On Wed, 13 Jul 2022 14:33:49 GMT, Raffaello Giulietti <[email protected]> wrote:
>> Initial implementation.
>
> test/jdk/java/lang/Float/SixteenBitFormats.java line 239:
>
>> 237: public static boolean isNaN(short binary16) {
>> 238: return ((binary16 & 0x7c00) == 0x7c00) // Max exponent
>> and...
>> 239: && ((binary16 & 0x03ff) != 0 ); // significand
>> nonzero.
>
> return (binary16 & 0x7fff) > 0x7c00;
>
> is more concise
In this case, I think the more verbose coding pattern is clearer.
> test/jdk/java/lang/Float/SixteenBitFormats.java line 244:
>
>> 242: public static short negate(short binary16) {
>> 243: return (short)(((binary16 & 0x8000) ^ 0x8000) | // Isolate
>> and flip sign bit
>> 244: (binary16 & 0x7fff));
>
> return (short)(binary16 ^ 0x8000);
>
> is shorter
Good suggestion.
-------------
PR: https://git.openjdk.org/jdk/pull/9422