Is this bogus or what?
Mark Roddy
mroddy at enmasse.UUCP
Fri Mar 8 06:24:23 AEST 1985
> > Basic: if A=1 and B=1 goto 104950393040 [:->
> > C: if (A==1 & B==1) foobar();
> > Which works, of course, but it was clear from the context that the author
> > thought that '&' and logical AND were identical!!!! -- Mark Roddy
>
> It doesn't work if A == 1 and B == 3. It calls foobar when it shouldn't.
from K&R:
"Note that the precedence of the bitwise logical operators
&,^ and | falls below == and !=."
pp. 49 The C Programming Language
The order of evaluation is ((A==1) & (B==1)), for (A,1), (B,3),
your compiler should evaluate ( (1) & (0) ) to be 0.
[short pause here while the author determines, through a
small experiment, if he is talking through his hat
yet again.]
[okay, we`re back, ego intact. K&R and moi all agree on what C is]
I do stand corrected however, the Creative Computing article
read ((A==1) & (B==1)).
The point really was about the utter crapola that goes out in
some of the home computer rags.
If your compiler behaves the way you suggest, I'd send it back.
--
Mark Roddy
Net working,
Just reading the news.
(harvard!talcott!panda!enmasse!mroddy)
More information about the Comp.lang.c
mailing list