On Wed, 26 Apr 2023 01:41:09 GMT, Joe Darcy <da...@openjdk.org> wrote:
>> A reimplementation of `BigDecimal.[double|float]Value()` to enhance >> performance, avoiding an intermediate string and its subsequent parsing on >> the slow path. > > src/java.base/share/classes/java/math/BigDecimal.java line 308: > >> 306: /* >> 307: * Let l = log_2(10). >> 308: * Then, L < l < L + ulp(L) / 2, that is, L = roundTiesToEven(l). > > It doesn't matter in terms of the code, but shouldn't this be something like: > > L - (ulp(L)) < l < L ulp(L) > > In other words, without further checking, it isn't clear that L is the > lower-bound of the two double value bracketing l. > > (If the ulp function being discussed were the real-valued version than L +/- > ulp(l) would also be a reasonable formulation.) While it isn't obvious from the definition, high precision computations reveal that the inequalities `L < l < L + ulp(L) / 2` do indeed hold. But as noted, this is not really relevant for the rest of the analysis. > src/java.base/share/classes/java/math/BigDecimal.java line 3777: > >> 3775: return 0.0f; >> 3776: } >> 3777: BigInteger d = unscaledValue().abs(); > > I'd prefer a name other than "d" be used for the BigInteger significand's > magnitude. I have no objections as long as it is a 1 letter name that does not conflict with others. Have you a preferred one? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/9410#discussion_r1177496610 PR Review Comment: https://git.openjdk.org/jdk/pull/9410#discussion_r1177500421