On Wed, 9 Oct 2024 17:25:12 GMT, fabioromano1 <d...@openjdk.org> wrote:
>> If you are interested, you can create new PRs without reference to JBS >> issues, and I'll file them. >> As usual, it's easier for review purposes when each PR touches only small >> groups of strongly related changes rather than big modifications en-bloc. >> >> But you should show JMH benchmark evidence in later comments (not the >> introductory comment) that there are no performance regressions, in addition >> to code simplification. > > @rgiulietti I think I just found a problem much more serious than a simple > optimization, I'm afraid the semantics of `BigInteger.bitCount()` is > ill-defined, although it seems absurd to me that no one has noticed it so > far... What's wrong with the semantics? In my understanding, it should count the ones for non-negative values and the zeros for negative values, where non-negative values have an infinite prefix of zero bits and negative values have an infinite prefix of one bits in two's complement representation. Note that this is different from `[Long|Integer].bitCount()`, which consider their arguments as finite width unsigned bit strings. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21323#discussion_r1794175124