this post was submitted on 15 May 2025
1148 points (98.6% liked)

Programmer Humor

23427 readers
1376 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[โ€“] NikkiDimes@lemmy.world 6 points 1 week ago* (last edited 1 week ago)

It's called bitshifting and is used to select which bits you want to modify so you can toggle them individually.

1 << 0 is the flag for the first bit
1 << 1 for the second
1 << 2 for the third and so on

I think that's correct. It's been years since I've used this technique tbh ๐Ÿ˜