> From: "Guy Steele" <[email protected]>
> To: "Brian Goetz" <[email protected]>
> Cc: "Remi Forax" <[email protected]>, "Angelos Bimpoudis"
> <[email protected]>, "amber-spec-experts"
> <[email protected]>
> 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:[email protected] |
>> [email protected] ] > 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 

Reply via email to