RFR: JDK-8323186: A faster algorithm for MutablebigInteger.divWord(long, int) [v3]

fabioromano1 duke at openjdk.org
Mon Jan 22 16:39:29 UTC 2024


On Mon, 22 Jan 2024 16:15:57 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> fabioromano1 has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Removed trailing whitespaces
>
> What about splitting the result of `divWord()` into its components `q` and `r` and check that `0 <= r < d` and `n == q * d + r`? Mathematically this should be sufficient. Perhaps you might need to take care about unsigned vs signed arithmetic.

@rgiulietti In this case, the unsigned arithmetic is not a problem, since `(d & LONG_MASK) > 0` and multiplication and addition semantics is equivalent in signed/unsigned integers. Perhaps, it would be better to call directly `Long.divideUnsigned(long, long)` and `Long.remainderUnsigned(long, long)` to possibly use directly assembly code, since they are annotated as IntrinsicCandidate.

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

PR Comment: https://git.openjdk.org/jdk/pull/17291#issuecomment-1904381418


More information about the core-libs-dev mailing list