Newsgroups: comp.lang.c
Path: utzoo!henry
From: henry@zoo.toronto.edu (Henry Spencer)
Subject: Re: using !
Message-ID: <1991Jan2.195137.1138@zoo.toronto.edu>
Organization: U of Toronto Zoology
References: <009417DC.37A9DCA0@cemmva.cem.msu.edu> <544@taumet.com> <639@saxony.pa.reuter.COM>
Date: Wed, 2 Jan 91 19:51:37 GMT

In article <639@saxony.pa.reuter.COM> dgil@pa.reuter.COM (Dave Gillett) writes:
>>>Is !(a > b) portable?
>>>slower or faster than  a <= b?
>
>     If you find a compiler that generates different code for the two cases,
>it is most likely to have crudely generated code for the !(a > b) case...

While I agree with Dave's comments in general, there is a subtle issue here
which may be worth mentioning:  `!(a > b)' and `a <= b' are *NOT NECESSARILY
EQUIVALENT* for floating point.  In some floating-point representations,
notably the IEEE standard which is everywhere now, there are floating-point
values which compare "unordered" against normal numbers.  That is, `a < b',
`a == b', and `a > b' may all be false, in which case `!(a > b)' and `a <= b'
have different values.
-- 
"The average pointer, statistically,    |Henry Spencer at U of Toronto Zoology
points somewhere in X." -Hugh Redelmeier| henry@zoo.toronto.edu   utzoo!henry
