RFR: 8279986: methods Math::asXExact for safely checked primitive casts

Raffaello Giulietti duke at openjdk.java.net
Thu May 5 14:36:20 UTC 2022


On Thu, 5 May 2022 10:11:05 GMT, Raffaello Giulietti <duke at openjdk.java.net> wrote:

> Add a family of "safe" cast methods.

The JLS specifies that the cast (officially, "narrowing primitive conversion") (long)-0.0 returns 0L.
As these methods are meant to be safer casts, I think we should follow the JLS as closely as possible.

Besides, throwing on -0.0 would make the implementation slightly more convoluted. We want C2 to emit efficient inlineable code.

So, what is the use case or the rationale for throwing on -0.0?

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

PR: https://git.openjdk.java.net/jdk/pull/8548


More information about the core-libs-dev mailing list