www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/03/09:29:39

From: Ian Miller <itmiller AT dra DOT hmg DOT gb>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: how to interpret this...
Date: Tue, 03 Dec 1996 12:45:00 +0000
Organization: DRA
Lines: 21
Message-ID: <32A420CB.41C67EA6@dra.hmg.gb>
References: <57ve1o$rfk AT lyra DOT csx DOT cam DOT ac DOT uk>
NNTP-Posting-Host: 146.80.115.106
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019