On Wed, 9 Oct 2024 15:18:15 GMT, fabioromano1 <d...@openjdk.org> wrote:
>> An optimized algorithm for `BigDecimal.stripTrailingZeros()` that uses >> repeated squares trick. > > fabioromano1 has updated the pull request incrementally with one additional > commit since the last revision: > > Store log5(2) in BigDecimal src/java.base/share/classes/java/math/BigDecimal.java line 5260: > 5258: // a multiple of 10^n must be a multiple of 2^n > 5259: int powsOf2 = intVal.getLowestSetBit(); > 5260: long remainingZeros = Math.min(scale - preferredScale, powsOf2); Please document the semantics of this variable, preferably in maths, like inequalities, etc. src/java.base/share/classes/java/math/BigDecimal.java line 5270: > 5268: intVal = intVal.shiftRight(powsOf2); // remove powers of 2 > 5269: // maxPowsOf5 == ceil(log5(intVal)) roughly > 5270: long maxPowsOf5 = (long) Math.ceil(intVal.bitLength() * > LOG_5_OF_2); Please document the meaning of this variable in form of inequalities w.r.t. `intVal`. Also, shouldn't it be named `maxExpOf5` or similar? It's an exponent, after all. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21323#discussion_r1795743150 PR Review Comment: https://git.openjdk.org/jdk/pull/21323#discussion_r1795743514