Reverse bits of an unsigned integer.

# Category Archives: bit operations

# Number of 1 bits

Write a function that takes an unsigned integer and returns the number of ‘1’ bits it has.

# Fun with Bit Operations

What does the following function mystery() do?

1 2 3 |
bool mystery(unsigned int x) { return !(x & (x-1)); } |

# Problem A: Snapper Chain Solution (Google Code Jam Qualification Round 2010)

Read the question here from GCJ Qualification Round 2010:» Problem A: Snapper Chain