Thursday, February 3, 2011

Detecting a number odd or even


If (x&1==1)
Then x is a odd number. Because every odd number must have a 1 in its last bit.
Like,  3 => 101

so when ANDing with 1, it produce 1 if it odd, else not.



No comments:

Post a Comment