0 Members and 2 Guests are viewing this topic.
template <class T>bool retrievebit(T source, int bit){ if(bit > (sizeof(T)*8)) throw "Too large"; return ((source >> (bit-1)) & 1);}
int retrievebit(char source, int bit){ if(bit > 8)) return -1; return ((source >> (bit-1)) & 1);}
#define getBit(x,n) x&(1<<n)
Actually, this could work:Code: [Select]#define getBit(x,n) x&(1<<n)
#define getBit(x,n) ((x&(1<<n))>>n)
QuoteActually, this could work:Code: [Select]#define getBit(x,n) x&(1<<n)Nope Code: [Select]#define getBit(x,n) ((x&(1<<n))>>n)
#define getBit(x,n) ((x)>>(n)&1)