Interview
Friday, July 16, 2010
Bitwise operator's tricks and questions
To find out if a value is even
return ((i & 1) == 0)
To see if a number is a power of 2 (2^n)
return ((i & -i) == i); or return ((i & (i -1)) == 0); //By My Friend Zolio
Bitwise Tricks
Bit Twiddling Hacks
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment