bitwise & and modulus %2 operator speed comparison



i dont remember the source but i had read somewhere that bitwise & of n with 1 to check if its even or odd is faster than checking n%2 . but while solving the problem traversing the grid, i checked if n is odd or even and same for m.
in that i found the version of code which had % operator ran in 0.00
and the one with bitwise & ran in 0.03 and 0.02 (i ran this code two times) rest all code was same.
per test case i am checking only one time the two numbers about even and odd. Can someone tell which is faster and if possible, give reasons


Such a small difference in performance is because of the SPOJ server. Try submitting the same solution twice and you may see a difference of 0.01-0.02 due to the load on the server. Plus, majority of the execution time of the code is because of input/looping, therefore using ‘&’ operator though faster, is unable to provide a concrete speed up in this case.