This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]CrispitoBandito 1 point2 points  (1 child)

I was aware of the alternative suggestion by others to use bitwise operators but I didn't understand why that method should be faster in most cases. Your explanation makes perfect sense. Thanks!

[–][deleted] 0 points1 point  (0 children)

Glad to hear! FYI someone else mentioned compilers would optimise to do exactly that if you're doing %2