On Fri, 20 Nov 2026 16:42:28 GMT, Paul Sandoz <[email protected]> wrote:

> > While I understand the rationale of this proposal, I think it would be 
> > wiser to wait until a general numeric conversion mechanism is discussed in 
> > the context of Valhalla explorations related to Java numerics. Even with 
> > this proposal in place, a `Float16`->`byte` conversion would still expose 
> > the same sin as JLS 5.1.3 currently does for, say, `float`->`short`.
> 
> Thanks Raffaello, yes that's a very good point, I am glad you brought it up. 
> I was thinking more about this today and wondering what we might do with say 
> 128-bit and 8-bit floating point conversions. So I agree it is best to do 
> nothing right now, including any optimization work. It requires more broader 
> thinking and exploration before we can make the best informed decision.

A few thoughts on this general topic.

First, the JLS conversion rules include assumptions appropriate for the 
mid-1990's design period of the platform, types smaller than 32-bits only have 
partial support, etc. With the rise of LLMs, there is now more interest in 
operations on 16 bit, 8 bit, and maybe 4 bit(?) integral and floating-point 
types.

When there are floating-point and integral types of the same size, I think it 
is sensible to have a "direct" conversion as one of the conversions the 
platform provides, as done already for `int` <-> `float` and `long` <-> 
`double`. So, I think providing a direct `Float16` <-> `short` conversion is 
technically reasonable, even if done using a method other than `shortValue()` 
from the `Number` abstract class.

As an incubating API, we have more flexibility in making behavioral 
compatibility changes, including larger changes than would be acceptable in 
preview or permanent APIs.

So I don't think it is strictly necessary to change the behavior of 
`Float16.shortValue` at this point in time, but I think it would be acceptable 
to do so too in the interest of experimentation.

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

PR Comment: https://git.openjdk.org/jdk/pull/33980#issuecomment-7051294414

Reply via email to