# Binary Birthday Candles

Emilie/ September 18, 2020/ animal crossing, computers, mathematics, video games/ 0 comments

I celebrated my birthday this week. Since traditional birthday parties where you are surrounded by family (blood or chosen) aren’t really an option this year, I opted to celebrate by streaming a party on my Animal Crossing island, indulging in homemade mac n cheese, and ordering a delicious cake.

I can’t stop talking about this cake. Even before it arrived, I was raving about it. I first saw Milk Bar’s Birthday Cake on a sponsored Instagram post and admittedly ordered it based on aesthetics. The cake went beyond my expectations, but more on that later.

I thought it’d be clever to take a tech-y approach to the candles on my cake. Typically you’d adorn one candle per year, but that would have been a lot of candles for a relatively small, frosted surface. I instead decided to use a **binary** representation of my numerical age instead.

# Number Systems

## Decimal Numbers

When you think of a number, you’re likely thinking of it in its decimal form, or base 10 (the prefix “deci” comes from the Latin word *decimus* which means “tenth”). Humans generally use the decimal number system since many of us have 10 fingers for counting. Consider the number 142, for instance. You likely read that as “one hundred and forty-two.” Why, though? Let’s go back to when we were first learning about number “places.”

The number 142 has:

- 1 “hundreds”
- 4 “tens”
- 2 “ones”

Each digit (1, 4, and 2) is written in its respective spot in a particular order. Note that our commonly-used decimal system uses powers of 10 to measure the value of each digit. Starting from the right-most place we have the following:

- \(10^0=1\)
- \(10^1=10\)
- \(10^2=100\)
- \(10^3=1000\)
- and so on

You’ll see in the above pattern we get 1, 10, 100, 1000, etc. These powers of ten are the values of the places for our decimal numbers. The goal is to write down the number from left to right, giving it the largest digit possible for that place. Looking again at what we had above, 142 has:

- 1 “hundreds” with 42 left over
- \(142 – 1 \cdot 10^2 = 142 – 1 \cdot 100 = 42\)

- 4 “tens” with 2 left over
- \(42 – 4 \cdot 10^1 = 42 – 4 \cdot 10 = 2\)

- 2 “ones” with nothing left over

## Binary Numbers

You know how I mentioned earlier that humans generally use decimal (base 10) numbers since most of us have 10 fingers? Well, computers don’t! Computers don’t really have fingers at all. Instead, they count using their electronic components. In the simplest form, an electronic component has two states, on and off. In that sense, computers only have two fingers! Because of this, the decimal number system isn’t ideal. This is where the binary number system comes into play.

Binary numbers and decimal numbers represent the same values, they just show these numbers differently. In the decimal number system, each place represents a power of ten, and can be filled with a digit of 0-9. In the binary number system, each place represents a power of *two*, and can be filled with either a 0 or a 1 for a digit. Before diving too far into binary numbers, then, we need to review the powers of two:

- \(2^0 = 1\)
- \(2^1 = 2\)
- \(2^2 = 4\)
- \(2^3 = 8\)
- \(2^4 = 16\)
- and so on

Going from right to left, this means that binary numbers have a “ones” place, a “twos” place, a “fours” place, an “eights” place, a “sixteens” place, and so on (very similar to the “ones” place, “tens” place, “hundreds” place, etc. in the decimal system).

## Converting from Decimal to Binary

Let’s consider the decimal number 13, and instead write it in its binary form. To do this, we first have to find the largest power of two that “fits into” the decimal value 13. 16 is too large, but 8 works. Following the places outlined above by the powers of two, this means we have:

- 1 “eights” with 5 left over, since:
- \(13 – 1 \cdot 2^3 = 13 – 8 = 5\)

- 1 “fours” with 1 left over, since:
- \(5 – 1 \cdot 2^2 = 5 – 4 = 1\)

- 0 “twos” since we only have 1 left
- 1 “ones” with nothing left over

Placing these digits in their places, we get the binary representation 1101. The decimal number 13 is 1101 in binary.

Try writing 142 in binary. Hint: you’ll need to write out more powers of two!

## Converting from Binary to Decimal

Going this direction is actually a bit easier. Let’s say we have the binary number 1010. To find the decimal representation, you simply add up the “places” that have a 1. In the binary number 1010, we have:

- 0 in the “ones” place
- 1 in the “twos” place
- 0 in the “fours” place
- 1 in the “eights” place

Since the “twos” and “eights” place have a 1, we add 2 and 8 to get 10. Thus, 1010 in binary is 10 in decimal.

Try converting 11101 from binary to decimal. Hint: consider how many powers of two you need to write out here.

# Candles in Binary

This CAKE though – look at it in all its deliciousness!

You’ll notice that my cake has five candles, three pink, one blue, and one more pink. No, I did not just turn five years old. My age is instead represented in binary through my candles.

Can you figure out how old I turned? Hint: the pink candles are 1s and the blue are 0s.

While you figure that out, I’m going to help myself to another slice of colorful cake.