Re: [Dev-C++] The & in a conditional statement.
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <cg...@wo...> - 2003-04-26 16:12:06
|
It's performing the logical AND operation with m_afConditions and
iConditions, if the result is different from zero (true) return true,
else return false. (Notice that would be shorter do [...]{return
m_afConditions & iConditions;})
To be true at least one of the bits which is set in m_afConditions has
to be in iConditions.
AND true table:
1 AND (&) 1 = 1 (true)
1 AND (&) 0 = 0 (false)
0 AND (&) 1 = 0 (false)
0 AND (&) 0 = 0 (false)
Daniel Glenfield wrote:
> Hi, I'm using the Half Life SDK and am confused by the ampersand
> symbol, can anyone explain what's happening please?
>
> inline BOOL HasConditions( int iConditions ) { if ( m_afConditions &
> iConditions ) return TRUE; return FALSE; }
>
> I also notice we have return TRUE; return FALSE; I'm assuming this is
> perfectly valid as in
>
> if (condition)
> return TRUE;
>
> // if condition was true we would have exited by now.
> return FALSE;
>
> This isn;t relating to HL, it's just a general question about the
> conditional statement. Is it something to do with bit masking?
>
>
>
>
>
> _________________________________________________________________
> Surf together with new Shared Browsing
> http://join.msn.com/?page=features/browse&pgmarket=en-gb&XAPID=74&DI=1059
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|