I have the follow:
public static final int LIMIT_ONE = 1;
public static final int TRADEABLE = (1 << 1);
public static final int SELLABLE = (1 << 2);
public static final int STORABLE = (1 << 3);
public static final int STORABLE_IN_WH = (1 << 4);
public static final int STORABLE_IN_LEGION_WH = (1 << 5);
public static final int BREAKABLE = (1 << 6);
public static final int SOUL_BOUND = (1 << 7);
public static final int UNK9 = (1 << 8);
public static final int UNK10 = (1 << 9);
public static final int UNK11 = (1 << 10);
public static final int CAN_COMPOSITE_WEAPON = (1 << 11);
public static final int BLACK_CLOUD_TRADERS = (1 << 12);
public static final int CAN_SPLIT = (1 << 13);
public static final int UNK15 = (1 << 14);
public static final int UNK16 = (1 << 15);
and I wanted to understand how it is calculated to give the follow result, for example: 12414
I am really clueless on how the bitmask work and if any one could perhaps give some tips and explain how it goes to that number I would appreciate very much.
The expression
(1 << n)is equivalent to 2 raised to the power of n.When you write
(1 << n) | (1 << m)this is the same as(1 << n) + (1 << m)as long asnandmare different. So you can think of it in terms of simple additions if you wish.The number
12414in binary is11000001111110so it is the sum (or bitwise OR) of the following flags:TRADEABLE 1 << 1 = 2 SELLABLE 1 << 2 = 4 STORABLE 1 << 3 = 8 STORABLE_IN_WH 1 << 4 = 16 STORABLE_IN_LEGION_WH 1 << 5 = 32 BREAKABLE 1 << 6 = 64 BLACK_CLOUD_TRADERS 1 << 12 = 4096 CAN_SPLIT 1 << 13 = 8192 ======================================== Total = 12414Note that the flags that are included correspond to the bits that are set in the binary representation of 12414, when read right-to-left.