Mail Archives: djgpp/1996/12/03/09:29:39
G.P. Tootell wrote:
> i'm used to doing a=b=c=0; to set more than one variable at a time, and by error
> i had extended this analogy to if (a==b==c==0) { do stuff }...
> instead of treating this as a==b && b==c && c==0, it treated it as a==b && c==0
> can anyone explain this behavior? should it not have been reported as a warning?
>
> nik
>
> --
I'd say it means (((a==b)==c)==0). (a==b) is 1 if they are the same
or 0 if they are different (logical true or false). So it becomes
((0==c)==0) if a!=b or ((1==c)==0) if a==b. Get the idea?
Basically, if you mean a==b && b==c && c==0
then you should write a==b && b==c && c==0.
I would write a==0 && b==0 && c==0 because it's clearer :)
--
Ian Miller, Dorset, UK
DJGPP 2.01, Win95 DOS box (LFN undefined, FNCASE=y)
- Raw text -