Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There's a fairly famous bit twiddling hacks site hosted at Stanford but I find this interpretation is more accessible, and has a better breakdown, and more accessible code examples. Here's the page that's all about using the bitwise operations to query the status of the kth bit in a binary sequence:

https://www.techiedelight.com/bit-hacks-part-2-playing-kth-b...

Incidentally, deciphering some unknown bitwise expression is a task that ChatGPT excels at. For example, try asking it to do a stepwise breakdown and summary of:

unsigned int a, b, mask, r;

r = a ^ ((a ^ b) & mask);



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: