How do we flip bits in a integer from p1 to p2 locations in C? Here is the macro for it.
#define flip_bits(x, p1, p2) (x ^ (((unsigned int)~0 >> ((sizeof(int) * 8) - (p2-p1+1))) << p1))
Thursday, April 23, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment