I recently learned of the trick for finding out if a binary number is odd or even.
If the last bit in the number is 0, then the number is even. If it ends in a 1, then the number is odd.
In the tutorial in which I read this, is stated that this could be applied to programming if you "AND" the number with the binary number 1.
In another tutorial that I read, they said that is could applied if you "OR" the number with binary 0.
In regards to efficiency, which method would be more efficient for finding out if a number is odd or even?
Aucun commentaire:
Enregistrer un commentaire