lua - Converting decimal number to flag values -


I have some constraints, such as:

  hit = 0x1 = 0x2 remote_interested = 0x4 Remote_choose = 0x8 support_extensions = 0x10 local_connection = 0x20 handshake = 0x40 connecting = 0x80 queue = 0x100 on_parole = 0x200 seed = 0x400 optimist_choc = 0x800 rc4_encrypted = 0x100000 plain-text-encrypted = 0x200000  

And the document tells me 'The flag characteristic tells you which state the peers are inside. It is set up for any combination of above ' so basically I call dll and it fills in decimal with the decimal number that represents the flag in the structure, some examples:

  2086227 170 2098227 106  

How do I set flags from decimals?

To determine which flags were set, you need to perform operations (in Lua 5.2) Need to use. For example:

  is the function haslags (int, ...) local all = bit32.bor (...) return bit32.band (int, all) == if all the end is flags (2086227, interesting, local_connection) - Do something interesting and local_connection end  

Comments

Popular posts from this blog

eclipse plugin - Run java code error: Workspace is closed -

ios - How do I use CFArrayRef in Swift? -

scala - Play Framework - how to bind form to a session field -