Hacker News .hnnew | past | comments | ask | show | jobs | submitlogin
The Magic of Bits “Bitwise” (gitbook.io)
17 points by CoolerVoid on July 12, 2022 | hide | past | favorite | 7 comments


The target audience seems to be an intersection of people who are decently familiar with C and people who haven't been exposed to bitwise arithmetic.


and, it doesn’t seem to be proofread.


In words, you can think of XOR as: True when both bits are different.

---

Although the post is an introduction, I wanted to share a nice tip for coding multiplexers with bitwise operations:

https://blog.uidrafter.com/bitwise-table-lookup

---

And here's a fun example, KITT-like lights, for practicing bitwise operations:

https://ericfortis.github.io/web-animations/#-kitt-like-ligh...

Source Code:

https://github.com/ericfortis/web-animations/blob/main/kitt-...


The book linked at the bottom is a treasure trove of bitwise fun:

"Hackers Delight" https://www.amazon.com/Hackers-Delight-2nd-Henry-Warren/dp/0...


One fun way to get familiar with bitwise operations is writing a virtual machine, as it involves a lot of masking and shifting bits from instructions to extract relevant pieces (dare I say bits) of information. If anyone is interested in going this route, I recommend LC-3, as it's very straightforward.

https://www.jmeiners.com/lc3-vm/


Reminded me of Thinking Forth (http://thinking-forth.sourceforge.net). Lookup tables FTW.


one of my pet peeves of common computers is that they don't have a generalized LUT2 instruction. why do you pick out a handful of specific bitwise ops for me when all 16 are lying in reach! a mere 4 bit look up table!

    let ix = a | b<<1
    (lut & (1 << ix)) >> ix




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: