PDA

Click to See Complete Forum and Search --> : C# Code Confirmation


Dilvid
Sep 26th, 2005, 04:37 PM
Lo all just wondering if someone could just confirm what this code does. I have my ideas just would like it confirmed.


int flags = 0x3 | m_AdditionalFlags;

if ( Core.SE )
flags |= 0x0040;

if ( Core.AOS )
flags |= 0x801C;

if ( acct != null && acct.Limit >= 6 )
{
flags |= 0x8020;
flags &= ~0x004;
}


Does it translate in pseudo as...

Flags = 0x03 or m_AdditionalFlags
if core.se is true then flags = 0x0040
if core.aos is true then flags = 0x801c
if acct is not null and acct.limit is greater or equal to 6 then
{
flags = 0x8020
flags = flags + 0x004
}


am i right in what ive wrote or is it like...

if core.se is true then flags = flags + 0x0040
if core.aos is true then flags = flags + 0x801c

Hope someone can help...

jmcilhinney
Sep 26th, 2005, 07:49 PM
flags |= 0x0040 <=> flags = flags | 0x0040

i.e. flags is bit-wise ORed with 0x0040. Bit-wise OR means that the result will have any particular bit set, i.e. equal to 1, if and only if that same bit is set in either one or both of the operands. A bit-wise AND will set a bit if and only if that same bit is set in both operands.