#define HEXIFY(X) 0x##X##LU #define B8IFY(Y) (((Y&0x0000000FLU)?1:0) + \ ((Y&0x000000F0LU)?2:0) + \ ((Y&0x00000F00LU)?4:0) + \ ((Y&0x0000F000LU)?8:0) + \ ((Y&0x000F0000LU)?16:0) + \ ((Y&0x00F00000LU)?32:0) + \ ((Y&0x0F000000LU)?64:0) + \ ((Y&0xF0000000LU)?128:0)) #define B8(Z) ((unsigned char)B8IFY(HEXIFY(Z)))
B(01011010)
If you like this, see my blog post about bithacks.h:
http://www.catonmat.net/blog/bit-hacks-header-file/
If you like this, see my blog post about bithacks.h:
http://www.catonmat.net/blog/bit-hacks-header-file/