Draft JEP on Primitive types in patterns, instanceof, and switch

Guy Steele guy.steele at oracle.com
Thu Jan 26 15:25:16 UTC 2023



On Jan 26, 2023, at 9:36 AM, Brian Goetz <brian.goetz at oracle.com<mailto:brian.goetz at oracle.com>> wrote:

...

For comparing a variable to a constant, representational equality is the obvious interpretation; `case nnn` means "is it the number nnn".  This allows you to say `case NaN` and `case -0` and get the right answer (all of these relations agree on what to do about 1.0).

Careful: I think you had better say “case -0.0”; otherwise the constant expression “-0” will be reduced to “0” and only then converted to floating-point representation, producing +0.0.

Yes, floating-point is VERY fiddly.

—Guy

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-spec-experts/attachments/20230126/cf70d69e/attachment.htm>


More information about the amber-spec-experts mailing list