skip to main
|
skip to sidebar
The Riddle Spot
Wednesday, April 25, 2007
#27
Reverse the bits of an unsigned integer.
Answer:
#define reverse(x) \
(x=x>>16(0x0000ffff&x)<<16,>
x=(0xff00ff00&x)>>8(0x00ff00ff&x)<<8,>
x=(0xf0f0f0f0&x)>>4(0x0f0f0f0f&x)<<4,>
x=(0xcccccccc&x)>>2(0x33333333&x)<<2,>
x=(0xaaaaaaaa&x)>>1(0x55555555&x)<<1)
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
powered by
arnabpal.blogspot.com
Search
Labels
bit twiddling
(4)
data stuctures
(2)
logic
(18)
numbers
(7)
picture clues
(7)
programming
(14)
series
(3)
words
(7)
No comments:
Post a Comment