On Tue, 26 Nov 2024 17:04:49 GMT, fabioromano1 <d...@openjdk.org> wrote:

>> OK.
>> But for the sake of completeness, I would add at least one test case for an 
>> overflowing `workingScale`.
>> 
>> Other than that, the PR is then in good shape for approval.
>
>> OK. But for the sake of completeness, I would add at least one test case for 
>> an overflowing `workingScale`.
> 
> I'm afraid it's not possible to produce such a test case, with the current 
> implementation of `BigInteger`.
> Indeed, `workingScale` is defined by `workingScale = this.scale - normScale`, 
> and `normScale` by:
> 
> long normScale = minWorkingPrec - this.precision() + this.scale;
> normScale += normScale & 1L;
> 
> Therefore `workingScale ==  this.precision() - minWorkingPrec - (normScale & 
> 1L)`, so to overflow `workingScale` it is necessary to maximize 
> `this.precision()`, thus`this.intVal` must have at least `Integer.MAX_VALUE + 
> 1` digits, but `BigInteger.TEN.pow(Integer.MAX_VALUE)` surely exceeds the 
> supported range for  `BigInteger`s...

Actually, this proves also that `workingScale` should never overflow...

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21301#discussion_r1858943929

Reply via email to