Live data from Hacker News

Understanding the power of bitwise operators

deusinmachina.net

41–48 of 48 posts

Re: Understanding the power of bitwise operators

#41
post #29

Earlier quoted context omitted.

Tangential aside we've collectively made a mistake using A-F for HEX representation. Alphabetical order seemed obvious at the time, but there's a far more literal option that's just pleasing on a visceral level. LHTIFE. The horizontal lines of each letter are literally encoding binary information. True there's no letter encoding 3 in this block style but that can either be invented or ignored. Or you can fudge the pa…

That would be a trivia to have to know, otherwise it just looks like a mess of arbitrarily chosen letters. The binary patterns shown on the chosen letters do not match the actual binary patterns those letters represent. And then you don't try to do the same with 0 to 9 which makes the whole effort half-baked.

Just going to point out real quick that the lower left vertical on a 7 segment display does in fact come extremely close to directly encoding even/odd. Write them all out and see for yourself. Only the number 4 breaks the pattern. That would only leave two bits not directly encoded in segments as far as anyone has noticed.

Re: Understanding the power of bitwise operators

#42
post #32
post #29

Earlier quoted context omitted.

Tangential aside we've collectively made a mistake using A-F for HEX representation. Alphabetical order seemed obvious at the time, but there's a far more literal option that's just pleasing on a visceral level. LHTIFE. The horizontal lines of each letter are literally encoding binary information. True there's no letter encoding 3 in this block style but that can either be invented or ignored. Or you can fudge the pa…

The I is a bad choice since it's similar to 1, using the letter Z instead would be much better. The letter T can't be mapped to a 7-segment display either, so if that's your goal you would need to use EFGHLP.

Also, yeah obviously T can't be mapped, but I still put T in the same category as all the other square intersecting grid letters. There are other, obviously repeating groupings that would work better on a different segmented basis. Some examples: diagonals {Z N X Y A V K 7 4 W M}, circle based {O G C Q D}, loopy: {B P b d q J S 8 9 3 }, 7 seg: {L H T I F E}

Re: Understanding the power of bitwise operators

#43
post #29

Earlier quoted context omitted.

> (e.g., Null character (�) a black diamond with white question mark in the middle). The description in the linked article is wrong, that's not a null character (U+0000) or ASCII's NUL. That black diamond symbol is U+FFFD the Unicode Replacement Character, it means "Something went wrong, so instead here is this symbol". For example if your decoder algorithm gets some gibberish and you can't or won't accept errors in…

Tangential aside we've collectively made a mistake using A-F for HEX representation. Alphabetical order seemed obvious at the time, but there's a far more literal option that's just pleasing on a visceral level. LHTIFE. The horizontal lines of each letter are literally encoding binary information. True there's no letter encoding 3 in this block style but that can either be invented or ignored. Or you can fudge the pa…

I've seen UVWXYZ. Less seriously, I've seen GBNJFL (Great Big Numbers Just For Laughs).

Re: Understanding the power of bitwise operators

#45
post #8

Who is this article for exactly? It starts off by trying to relate to the reader by presenting the point about learning a new programming language, but then goes on to explain one of the most fundamental concepts of computing, as if the reader is a complete novice. I would imagine that nearly every person with programming experience, whether that be formal or not, would have at least some familiarity with binary repr…

This seems to be addressed to people who want to hack game emulators for early game machines. So they cover the basics and then go on to a game emulator example.

In modern programming, bit-banging can usually be avoided. C++ and Rust both have bit fields in structs, and generics for sets of bits. If you're working on some data structure with AND, OR, and shift operations, that's kind of retro today. The compiler is probably better at doing that stuff than you are.

Re: Understanding the power of bitwise operators

#46
post #12
post #6

Is it an autocorrect issue or the writer only-heard-never-read that the "^" character is called a “carrot”?

The "^" character is correctly named the "caret".

Exactly! Hence the guesses: is it autocorrect or that the article author has heard the word but never seen it written that made them write it as “carrot”?

Re: Understanding the power of bitwise operators

#47
post #9

For folks that are interested in learning more about bitwise operations, here is another article (slightly more nuanced) about XORs that you may enjoy reading: All About XOR: https://accu.org/journals/overload/20/109/lewin_1915/

This is excellent, thank you.
Post reply on HN