This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fold sqrt comparisons against constants (take 3)


Roger Sayle <roger at www dot eyesopen dot com> writes:

|> On Wed, 19 Mar 2003, Geoff Keating wrote:
|> > > Date: Wed, 19 Mar 2003 12:08:06 -0700 (MST)
|> > > From: Roger Sayle <roger at www dot eyesopen dot com>
|> >
|> > > Unfortunately, not.  sqrt(NaN) != -1  ->  NaN != -1  ->  false
|> > >                      sqrt(-1)  != -1  ->  NaN != -1  ->  false
|> >
|> > NaN != -1 -> true
|> >
|> > In fact,
|> >
|> > NaN != x -> true for any 'x'.
|> 
|> 
|> I believe the logic is the other way around and all comparisons
|> against NaN always return false, for any of the comparison
|> operators.  This is why "NaN != x" is not the same as "!(NaN == x)".
|> 
|> But perhaps I'm getting confused?

NaN is always unequal to everything, even itself.  It's the "itself" part
that makes NaN special.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab at suse dot de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]