Bug 309087 - x!=x is true for double/float, iff x is NaN
Summary: x!=x is true for double/float, iff x is NaN
Status: VERIFIED DUPLICATE of bug 281776
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.6 M1   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-14 05:37 EDT by Sven Köhler CLA
Modified: 2010-04-26 14:50 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Köhler CLA 2010-04-14 05:37:38 EDT
Build Identifier: M20090917-0800

Consider the following source snippet:

double x = 1.0;
if (x != x)
{
  System.out.println("NaN");
}

Eclipse marks x!=x with a "Comparing identical expressions" warning. In our particular use-case, this doesn't make too much sense. According to the JLS, x!=x is true if and only if x is a NaN-value. So it can be used as a quick test for NaN. The opposite holds for x==x.

In our case, Double.isNaN is not available.

Please either add @SuppressWanrings support or don't show this wanring for float/double expressions.

Reproducible: Always
Comment 1 Ayushman Jain CLA 2010-04-14 06:01:46 EDT
This problem was fixed in bug 281776, and doesnt occur in the newer builds. Sven, can you please download the latest 3.6 milestone or I build?
Comment 2 Srikanth Sankaran CLA 2010-04-14 07:47:42 EDT

*** This bug has been marked as a duplicate of bug 281776 ***
Comment 3 Sven Köhler CLA 2010-04-14 10:04:20 EDT
(In reply to comment #1)
> This problem was fixed in bug 281776, and doesnt occur in the newer builds.
> Sven, can you please download the latest 3.6 milestone or I build?

I have downloaded 3.6M6 and everything seems to be fine now.
Comment 4 Olivier Thomann CLA 2010-04-26 14:50:31 EDT
Verified for 3.6M7 using I20100425-2000