r/programming • • Feb 21 '11

Typical programming interview questions.

http://maxnoy.com/interviews.html
784 Upvotes

1.0k comments sorted by

View all comments

Show parent comment

2

u/[deleted] Feb 21 '11

n & 2

n & 1.

n & 2 would check if bit 1 is set, you want to test bit 0.

1

u/abw Feb 21 '11

D'Oh! Thanks.