Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #11345

Re: behavior of || operator

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!.POSTED!not-for-mail
From Willem <willem@toad.stack.nl>
Newsgroups comp.lang.c
Subject Re: behavior of || operator
Date Fri, 7 Oct 2011 19:50:42 +0000 (UTC)
Organization Stack Usenet News Service
Lines 29
Message-ID <slrnj8um0i.tkv.willem@toad.stack.nl> (permalink)
References <j6nc0d$dii$1@speranza.aioe.org>
NNTP-Posting-Host toad.stack.nl
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Trace mud.stack.nl 1318017042 61578 2001:610:1108:5010::135 (7 Oct 2011 19:50:42 GMT)
X-Complaints-To abuse@stack.nl
NNTP-Posting-Date Fri, 7 Oct 2011 19:50:42 +0000 (UTC)
User-Agent slrn/0.9.9p1 (FreeBSD)
Xref x330-a1.tempe.blueboxinc.net comp.lang.c:11345

Show key headers only | View raw


Mark wrote:
) if ((action != ATTACH) || (action != DETACH))
)     puts("invalid action");

It looks like you don't understand De Morgan's laws.

In English:
If action is not attach or action is not detach, then it is an invalid
action.

What you wanted to do is this:
If action is not attach or detach, then it is an invalid action.

Which is:
 if (!(action == ATTACH || action == DETACH))
     puts("invalid action");

Which, according to De Morgan, is equivalent to:
 if ((action != ATTACH) && (action != DETACH))
     puts("invalid action");


SaSW, Willem
-- 
Disclaimer: I am in no way responsible for any of the statements
            made in the above text. For all I know I might be
            drugged or something..
            No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

behavior of || operator "Mark" <mark_cruzNOTFORSPAM@hotmail.com> - 2011-10-07 13:13 -0400
  Re: behavior of || operator James Kuyper <jameskuyper@verizon.net> - 2011-10-07 14:11 -0400
  Re: behavior of || operator John Gordon <gordon@panix.com> - 2011-10-07 18:47 +0000
  Re: behavior of || operator Willem <willem@toad.stack.nl> - 2011-10-07 19:50 +0000
  Re: behavior of || operator Gene <gene.ressler@gmail.com> - 2011-10-08 13:58 -0700

csiph-web