You can use the & operator to dispense with division in this example
It gives a slight performance advantage over % 2, but there is a subtle difference in its behaviour. You might find out what the subtle difference is if you change that code by replacing
& 1 by
% 2.
You can use the & and | operators to create and use masks.
You can use the shift operators instead of multiplying or dividing by 2, 4, 8, etc. Try
this old thread and see whether I have actually given you the correct link