www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/05/04/10:16:28

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
Message-ID: <20020504141614.99857.qmail@web11303.mail.yahoo.com>
Date: Sat, 4 May 2002 07:16:14 -0700 (PDT)
From: PEDRO IZECKSOHN <izecksohn AT yahoo DOT com>
Subject: Re: Can double negations get optimized out?
To: djgpp AT delorie DOT com
In-Reply-To: <5.0.2.1.2.20020504135729.009e3690@pop.gmx.net>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

   For me your code worked this way: ( b= !!a ) == ( b==a )
.
   I would write it this way:

//...
int a;
do {
scanf("%d",&a);
} while ( (a!=0) && (a!=1) );
//...

   or

//...
int a;
scanf("%d",&a);
if ( (a!=0) && (a!=1) ) { /* ... */ }
//...

--- Martin Steuer <martinSteuer AT gmx DOT de> wrote:
> For example:
> 
> [...]
> int a,b;
> scanf("%d",&a);
> b = !!a;
> [...]
> 
> I want to be sure that b can only be 1 or 0. Do i have to
> worry that this 
> is optimized out by a compiler? In my opinion i dont
> think so...
> 
> Thanks in advance for the info
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

- Raw text -


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