Demystifying bitwise operations, a gentle C tutorial
1–10 of 95 posts
Re: Demystifying bitwise operations, a gentle C tutorial
#2That's a nicely written piece, I wish it had been around when I was first struggling with bit-mangling.
Re: Demystifying bitwise operations, a gentle C tutorial
#3While it's based on C, a large chunk of the content is simply a great introduction to number representations in other bases such as binary and hexadecimal etc. Fundamental knowledge and very well explained, and a few insights I've not seen before.
Re: Demystifying bitwise operations, a gentle C tutorial
#4Some very interesting advent of code contributions written in Rust, available on github, use bitwise operations. Shout out to Tim Visee! https://github.com/timvisee/advent-of-code-2021/blob/master/...
Re: Demystifying bitwise operations, a gentle C tutorial
#5While it's based on C, a large chunk of the content is simply a great introduction to number representations in other bases such as binary and hexadecimal etc. Fundamental knowledge and very well explained, and a few insights I've not seen before.
Thanks, I wanted to post it after it was finished and revised. I also wanted to add more sections, but somebody was faster than I expected (thanks for posting it tod!). I suppose Getting to hn will add some valuable feedback in the first place.
I will probably add some more content in the coming weeks.
Re: Demystifying bitwise operations, a gentle C tutorial
#6I suppose the online list of hacks at the 1st reference in the OP [1] makes more sense, but I've got a fondness for the book "Hacker's Delight", which I've owned and browsed for many years now [2]. And checking on that, I see there was a 2nd edition issued 10 years ago. Hmm, might need to pick that up.
[1] https://graphics.stanford.edu/~seander/bithacks.html [2] https://en.wikipedia.org/wiki/Hacker's_Delight
Re: Demystifying bitwise operations, a gentle C tutorial
#7For many years I have recommended "Code" by Charles Petzold and published by microsoft. It's a great bathroom reader, reading on a road trip, or over a spaghetti dinner. It covers bottom up how computers work, starting out with - well what the heck are numbers and works up from there.
Re: Demystifying bitwise operations, a gentle C tutorial
#8I thought this was going to be ridiculous but it's actually a really good. It's clear enough that you could extend it down to showing how logic gates work.
The only thing missing is a little endian discussion; it assumes big endian (network byte order), and that may be confusing for all those x86 users out there.
Re: Demystifying bitwise operations, a gentle C tutorial
#9Articles like these seen today should make us value more the love and effort that requires to train people. Because there is no shortage of "love" and effort (and money) for training AI models.
Re: Demystifying bitwise operations, a gentle C tutorial
#10I don’t understand why bit masking and manipulation is so popular when it makes the code impossible to read. I like using Ruby, string, and pack and unpack.