Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
trying to understand bitwise operations
#4
Usually, caller passes flags using operator |, and function checks each flag using operator &. Flags can be 1, 2, 4, 8, 16, 32, 64, 128, 0x100, 0x200, 0x400, 0x800, 0x1000, and so on, until 0x80000000. Max 32 flags possible. You don't need to use or imagine how it looks in binary format.

caller:
Code:
Copy      Help
Function35 1|2

Function Function35
Code:
Copy      Help
function flags
if(flags&1)
,out "flag 1 is set"
if(flags&2)
,out "flag 2 is set"

or

Code:
Copy      Help
function flags
if(flags&1=0)
,out "flag 1 is not set"
if(flags&2=0)
,out "flag 2 is not set"


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)