using !
Henry Spencer
henry at zoo.toronto.edu
Thu Jan 3 06:51:37 AEST 1991
In article <639 at saxony.pa.reuter.COM> dgil at 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 at zoo.toronto.edu utzoo!henry
More information about the Comp.lang.c
mailing list