r/programminghorror • • Mar 03 '26

This pro gaming stuff is easy 😤

Post image
1.3k Upvotes

86 comments sorted by

View all comments

Show parent comment

3

u/BiedermannS Mar 04 '26

Binary "and" with 1 will be 1 for every odd number and 0 for every even number.

The rightmost bit has a value of 2⁰, which is 1.

3

u/justaregularwebdev Mar 05 '26

What do you mean? 1&1 == 1 which would then return true from isEven, which is not right. Either I'm missing something or you're baiting...

2

u/BiedermannS Mar 06 '26

Apparently we both can't read.

I misread the comment I was answering to and thought they wrote that binary and with one is 0 for odd numbers, which in hindsight is not what's written there.

I then corrected that by saying that and with 1 is always true for odd numbers and falls for even numbers. I did not claim that this makes the function true, just that the binary logic was wrong, because I misread.