On Fri, 2 Jul 2021 09:37:47 GMT, Andrew Haley <a...@openjdk.org> wrote:

>> Brian Burkhalter has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   8188044: Add @see links between multiplyHigh() and unsignedMultiplyHigh().
>
> src/java.base/share/classes/java/lang/Math.java line 1211:
> 
>> 1209:         long z1 = t >>> 32;
>> 1210: 
>> 1211:         return x1 * y1 + z1 + (z0 >>> 32);
> 
> Suggestion:
> 
>         long result = Math.multiplyHigh(x, y);
>         if (x < 0) result += y;
>         if (y < 0) result += x;
>         return result;

This is just subtracting the 2's-complement offset. I guess the idea, longer 
term, is that this be an intrinsic anyway, but if you do `unsignedMultiplyHigh` 
this way you'll utilize the existing `multiplyHigh` intrinsic on all platforms 
that have it.

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

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

Reply via email to