Re: Bitval Numbers

new topic     » goto parent     » topic index » view thread      » older message » newer message
ghaberek said...
Icy_Viking said...

Ah I found it, its just a #define like this

#define BITVAL(n) (1<<(n)) 

Perfect. In these cases, assuming these are meant to be bitwise flags, I define the values as hex constants and then document the original bitwise operation next to it, like this:

public constant 
    FLAG_ONE   = #01, -- 1 << 0 
    FLAG_TWO   = #02, -- 1 << 1 
    FLAG_THREE = #04, -- 1 << 2 
    FLAG_FOUR  = #08, -- 1 << 3 
    FLAG_FIVE  = #10, -- 1 << 4 
    FLAG_SIX   = #20, -- 1 << 5 
    FLAG_SEVEN = #40, -- 1 << 7 
    FLAG_EIGHT = #80  -- 1 << 8 

-Greg

Thanks Greg! Always helpful.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu