[lworld+fp16] RFR: 8339252: Add method float16Value() to BigInteger and BigDecimal [v2]

Jatin Bhateja jbhateja at openjdk.org
Tue Sep 3 12:15:44 UTC 2024


On Fri, 30 Aug 2024 13:01:09 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> This patch adds `float16Value()` to `BigInteger` and `BigDecimal`, as well as `Float16.valueOf(BigDecimal)`.
>
> Raffaello Giulietti has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase.

src/java.base/share/classes/java/math/BigDecimal.java line 3857:

> 3855:          *      2^12 = 2^{P+1} <= i < 2^{P+5} = 2^16
> 3856:          * Contrary to the double and float cases, here we cannot simply
> 3857:          * declare i as short, because P + 5 < Short.SIZE fails to hold.

Comment is not very clear here, can you please elaborate on the significance of augend '5' here.

test/jdk/java/math/BigInteger/PrimitiveConversionTests.java line 117:

> 115:         }
> 116: 
> 117:         BigInteger large = ONE.shiftLeft(1_000);

Nit: we can be strict here, and pass a value slightly greater than MAX_VALUE  + 0.5 * ULP(MAX_VALUE) i.e. 0x1.ffeP+15
`BigInteger large = BigInteger.valueOf(0x1.ffeP+15)`

Thereby avoiding shift left.

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/1228#discussion_r1741949169
PR Review Comment: https://git.openjdk.org/valhalla/pull/1228#discussion_r1741805989


More information about the valhalla-dev mailing list