RFR: 8341402: BigDecimal's square root optimization [v2]
fabioromano1
duke at openjdk.org
Mon Oct 21 15:56:27 UTC 2024
On Thu, 3 Oct 2024 00:47:23 GMT, Joe Darcy <darcy at openjdk.org> wrote:
> My initial question is what additional regression test cases should be added to probe the new code.
@rgiulietti @jddarcy This should be the path tree for the test cases of the algorithm, whether `signum == 1`:
If `mc.roundingMode == RoundingMode.UNNECESSARY || mc.precision == 0` (line 2165):
- If the input is an even power of 10:
- [ ] `result.scale < preferredScale` (line 2174);
- [ ] `result.scale > preferredScale` (line 2174).
- Otherwise, for both cases `result.scale > preferredScale` (line 2265) and `result.scale < preferredScale` (line 2267):
- for both cases `(strippedScale & 1) == 0` (line 2188) and `(strippedScale & 1) != 0` (line 2190):
- [ ] `sqrtRem[1].signum != 0` (line 2200);
- [ ] `sqrtRem[1].signum == 0 && (mc.precision != 0 && result.precision() > mc.precision)` (line 2200);
- [ ] `sqrtRem[1].signum == 0 && mc.precision == 0` (line 2200);
- [ ] `sqrtRem[1].signum == 0 && (mc.precision != 0 && result.precision() <= mc.precision)` (line 2200).
Otherwise (line 2202):
- [ ] `workingScale != (int) workingScale` (line 2217);
- for both cases `result.scale > preferredScale` (line 2265) and `result.scale < preferredScale` (line 2267):
- [ ] `mc.roundingMode == RoundingMode.DOWN || mc.roundingMode == RoundingMode.FLOOR` (line 2225);
- otherwise (line 2227):
- if `halfWay` (line 2232):
- [ ] `digit > 5` (line 2239);
- otherwise:
- if `digit == 5` (line 2241):
- [ ] `mc.roundingMode == RoundingMode.HALF_UP` (line 2242);
- otherwise:
- [ ] `mc.roundingMode == RoundingMode.HALF_EVEN && sqrt.testBit(0)` (line 2243);
- for both cases `mc.roundingMode != RoundingMode.HALF_EVEN` and `!sqrt.testBit(0)`:
- [ ] `sqrtRem[1].signum != 0` (line 2245);
- [ ] `sqrtRem[1].signum == 0 && working.compareTo(new BigDecimal(workingInt)) != 0` (line 2245);
- [ ] `sqrtRem[1].signum == 0 && working.compareTo(new BigDecimal(workingInt)) == 0` (line 2245);
- [ ] `digit < 5` (line 2241).
- if `!halfWay` (line 2249):
- [ ] `sqrtRem[1].signum != 0` (line 2251);
- [ ] `sqrtRem[1].signum == 0 && working.compareTo(new BigDecimal(workingInt)) != 0` (line 2251);
- [ ] `sqrtRem[1].signum == 0 && working.compareTo(new BigDecimal(workingInt)) == 0` (line 2251).
-------------
PR Comment: https://git.openjdk.org/jdk/pull/21301#issuecomment-2427077593
More information about the core-libs-dev
mailing list