On Mon, 9 Jan 2023 13:17:42 GMT, Raffaello Giulietti <rgiulie...@openjdk.org> 
wrote:

>> I see - thanks for the explanation - the problem is with `floatToIntBits` vs 
>> `floatToRawIntBits` in the "put" operation. The get operation is ok, but 
>> then having asymmetry where we use a float VH in one case (get) but not in 
>> the other (put) is not desirable.
>
> @mcimadamore According to the spec, `floatToRawIntBits` and 
> `doubleToRawLongBits` ensure that the original input bits are all preserved, 
> even for NaN values.
> On the other hand, the spec says that `intBitsToFloat` and `longBitsToDouble` 
> only ensure a best effort in preserving the output bits of NaN values.
> So I think `VarHandle` `get` and `put` do their best to preserve the bits, 
> but no more than the underlying platform can possibly offer.
> This behavior for floating-point values is not fully specified in 
> `VarHandle`, so there's room for improvement in the doc.

At least for the purposes of this PR, I think leaving the calls to the bitwise 
conversion methods in place is fine.

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

PR: https://git.openjdk.org/jdk/pull/11840

Reply via email to