TE
TechEcho
Home
24h Top
Newest
Best
Ask
Show
Jobs
English
GitHub
Twitter
Home
Looks like people are slowly forgetting about the modulus operator
4 points
by
narmak
about 7 years ago
1 comment
WeEatnKid
about 7 years ago
This particular use case (checking odd or even) doesn't even need to use the modulus operation -- which is expensive. A bitwise AND is much more efficient (provided that the compiler doesn't apply that optimization upon seeing % 2)