Implemented setbits function.

Exercise 2-6.