Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » "Comparing identical expressions"
"Comparing identical expressions" [message #542578] Fri, 25 June 2010 11:11 Go to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
In Eclipse 3.5.2 I get the following warning for
my comparator for doubles (offending lines marked with
a # in a comment):

public int compare(double x1, double x2) {
if (x1 < x2)
return -1;
if (x1 > x2)
return 1;
if (x1 != x2) {
if (x1 == x1) { // #1
return 1;
if (x2 == x2) { // #2
return -1;
return 0;

IMO this is a misleading diagnostic, because for
floating-point types all branches within this
test function can be reached. This is, so because
there can be NaN values tested. The reason for the whole
"if (x1 != x2)" block is to order NaN's relative to
non-NaN's. In Java it is guaranteed that an NaN values
evaluates != to true for *all* values, including
other NaNs.

In principle I like the warning category and would prefer
to switch it off locally, if possible, unfortunately
there seems not exist any SuppresWarning directive for
this one.

Any ideas how to get rid of the warning w/o switching
the category completly off? (And yes, I'm already using
project-specific warnings).

Thanks & Greetings from Bremen,

Daniel Krügler
Re: "Comparing identical expressions" [message #542688 is a reply to message #542578] Fri, 25 June 2010 15:41 Go to previous message
David Wegener is currently offline David WegenerFriend
Messages: 1379
Registered: July 2009
Senior Member
"Daniel Kr
Previous Topic:eclipse helio
Next Topic:Simple Feature Patch Question
Goto Forum:

Current Time: Sat Feb 13 12:56:42 GMT 2016

Powered by FUDForum. Page generated in 0.01782 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software