What the & 0xffffffff flag does in this example

Trying to convert a C program to Javascript since I found the old source code. The only thing I learn C when I go, but the hardest part is to be fresh to the language - you don’t know exactly what terms are for Google. Anyway,

I have this bit of code:

unsigned long long flag=0;

if (class[1]=='W') flag|=CF_WARRIOR;
else flag|=CF_MAGE;

The header file says

#define CF_WARRIOR (1ull<<16)

Then its last part:

(unsigned int)(flag&0xffffffff) // Assuming some sort of type casting followed by a bitwise &?

Just not sure what the programmer was trying to execute at that time.

Sorry for the bad question, but I don’t know exactly what Google should do to understand this, I understand that it 1ullis 1 unsigned long long and << 16is a bitwise shift. But not sure what he is doing |=, or flag&0xffffffff. Thanks.

+4
source share
1 answer

32 .

flag unsigned long long, 32.

C

+5

Source: https://habr.com/ru/post/1630016/


All Articles