r/ProgrammerHumor • • Oct 07 '26

Meme wasteOfPreciousSpace

Post image
7.3k Upvotes

244 comments sorted by

View all comments

Show parent comment

2

u/serge-mv Oct 07 '26

Did you not finish reading the one paragraph? Or what do you want to do an AND with?

1

u/Im_a_hamburger Oct 07 '26

Rather than having to write var >> 2 & 1 so var & 0b00000100

3

u/serge-mv Oct 08 '26

That's called a mask. Which is what I said to and with first. But you might not want to write out manually numbers like this and it would be easier to simply shift one number or the other. 1 << 2 & var is just as valid. It depends on both your preference and use case and produces the same exact result.

1

u/DrMobius0 Oct 08 '26

use enums dude