Inception of Dream
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 =>
10
1
so when ANDing with 1, it produce 1 if it odd, else not.
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment