Draft JEP on Primitive types in patterns, instanceof, and switch
forax at univ-mlv.fr
forax at univ-mlv.fr
Thu Jan 26 15:30:49 UTC 2023
> From: "Guy Steele" <guy.steele at oracle.com>
> To: "Brian Goetz" <brian.goetz at oracle.com>
> Cc: "Remi Forax" <forax at univ-mlv.fr>, "Angelos Bimpoudis"
> <angelos.bimpoudis at oracle.com>, "amber-spec-experts"
> <amber-spec-experts at openjdk.org>
> Sent: Thursday, January 26, 2023 4:25:16 PM
> Subject: Re: Draft JEP on Primitive types in patterns, instanceof, and switch
>> On Jan 26, 2023, at 9:36 AM, Brian Goetz < [ mailto:brian.goetz at oracle.com |
>> 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.
As i read the current spec, case -0 is equivalent to case 0, and you can not have both of them in the same switch.
> —Guy
Rémi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-spec-experts/attachments/20230126/5113b18e/attachment.htm>
More information about the amber-spec-experts
mailing list