Binary Numbers for Cocktail Party

Nerd out to the cool crowd without looking like one.

pancy
Code Zen

--

A one-arm T-Rex could have counted in binary.

We all know computers dream in binary numbers, or basically 0’s and 1’s. How many can actually remember how to read and write them out anyway? Here is a nifty trick to do that quickly, and shall I say, impress the cool crowd in the next party without boring them.

We count things in tens because we only had ten fingers (still do). We start off with 0 for nothing, then 1, 2, 3, … , up to 9, putting up one finger for each count. Then, because we ran out of fingers, we start anew by resetting the digit to 0 and add a new one, starting with 1, to represent the end of a person’s finger count. We call these Decimal numbers (Deci- for ten, anyone?).

Tangentially, if centipedes could count, they would have counted in Centimal using their legs, as creepy as that may be visually (Fact check: They don’t really have that many legs).

A centipede trying to count in Centimal (censored).

On the other hand, if you were a one-arm Tyrannosaurus Rex, you’d be left with nothing to count with but two little puny fingers. So you’d start getting creative and count with just those…

00 for 0 or nothing. (two fingers down)
01 for 1. (one finger down, one finger up)
10 for 2. (one finger up, one finger down)
11 for 3. (both fingers up)

… and holy moly, you poor imbecile giant bird-lizard, you ran out of fingers.

With two fingers, you can count up to 4 numbers (0 to 3). These are 2-bit Binaries.

With n bits, you can count exactly 2^n (reads 2 to the power n, thanks Medium for lack of variable support for superscripts), ranging from 0 to 2^n -1.

Now if I were a normal, two-arm T-Rex, how many numbers can I count in binary?

A T-Rex with 4 fingers is a 4-bit dinosaur, and it can count up to 2⁴ or 16 numbers from 0 to 15.

0000 = 0
0001 = 1
0010 = 2
0011 = 3
0100 = 4
0101 = 5
0110 = 6

1111 = 15

“How do you write a binary for 28?” A cute girl at the nearby table, overhearing your convo, asked.

That was a trick question, and you knew better than to fall for it. The right response would be another question, “How many bits are we talkin’?”

“6 bits,” She said.

In a decimal system, each digit carries a different power. For example, for number 129. The last digit carries the base of 10⁰, thus 9 · 10⁰ = 9. The 2 in the second digit, while is less than 9, sits in place with the power of 1 or 10¹. Thus, 2 · 10¹ = 2 · 10 = 20. Lastly, the first digit 1 has the value of 1 · 10² = 100. We add them up like 100 + 20 + 9 = 129.

Therefore, we can sum up what we learned as such:

129 = 1 · 10² + 2 · 10¹ + 9 · 10⁰
13001 = 1 · 10⁴ + 3 · 10³ + 0 · 10² + 0 · 10¹ + 1 · 10⁰
1000 + 200 + 8 = 1 · 10³ + 0 · 10² + 0 · 10¹ + 8 · 10⁰

It is very similar thinking in binary. Instead of base 10, we just replace each digit with base 2. Here is 28 in a 6-bit binary like she asked:

28 = 0 · 2⁵ + 1 · 2⁴ + 1 · 2³ + 1 · 2² + 0 · 2¹ + 0 · 2⁰
28 = 0 + 16 + 8 + 4 + 0 + 0
28 = 16 + 8 + 4
28 = 28

Thus, the answer is 011100.

Have fun partying, nerd.

--

--

pancy
Code Zen

I’m interested in Web3 and machine learning, and helping ambitious people. I like programming in Ocaml and Rust. I angel invest sometimes.