Photo by Jackie Luo.

Photos by Jackie Luo.

Today, in honor of winter break and hours of glorious free time, we’re going to show you how to make binary code doughnuts. What are binary code doughnuts, you ask? They are doughnuts in the shape of binary numbers. Why would you want to make them? Because you’ll learn something, and doughnuts. Doughnuts, people!

Some background on binary numbers:

The binary numeral system spans two digits: 0 and 1. It’s referred to as a Base-2 system of counting. You can compare it with our familiar decimal system, which spans the ten digits from 0 to 9 (a Base-10 system). Binary numbers are how computers count and interpret value, similar to how people use decimal numbers to do the same. Every action made by your computer is determined by many, many binary numbers that form a coded language that tells your computer what to do. Email, emojis, that face-swap filter on Snapchat…it’s all just a series of zeros and ones.

It also happens that doughnuts take the shape of 0s and 1s quite beautifully, which makes converting someone’s age to binary code doughnuts a breeze. If someone is 16, your doughnuts would spell 10000, which is 16 in binary. If you’re 15, it’s 1111. You can make a friend a binary-code birthday treat, or a sweet snack just because.

Before we dive into the doughnut-making process, let’s talk about converting decimal numbers to binary numbers. In the decimal system, you use combinations of digits from 0 to 9 to write out any number: 10; 24; 888; 9,451,234,559; et cetera. In the binary system, you use combinations of 0 and 1 (also referred to as “bits”) to write numbers: 0, 101, 01010, 1111001010101, and so on. Every number in the decimal system can also be expressed as a binary number, and vice-versa.

How to Convert Decimal Numbers to Binary Numbers

Today, we’ll convert the decimal number 19 to a binary number through two different methods.

Method One: Exponents

This method uses powers of two to convert decimal numbers to binary numbers. Binary numbers are often composed of eight bits (eight 1s and 0s) because that’s how many bits it takes to form a byte. A byte is a unit of data that computers use to make letters, numbers, symbols, and the like. So to start…

1. Make eight slots, one for each bit.

graph-1

2. Write the following numbers below each slot: 1, 2, 4, 8, 16, 32, 64, 128. Each of these numbers is an exponent of two.

graph-2

3. Now, write 1 in the slots that correspond to the numbers that will add up to your number. 1 + 2 + 16 = 19, so for 19 write 1 in the slots that correspond with 1, 2, and 16.

graph-3

4. Write 0s in the remaining slots:

graph-4

5. Almost there! The number you end up with here is backwards, so you’ll need to make it a mirror image of itself. In this case, 11001000 becomes 00010011. And 00010011 is 19 in binary!

With binary numbers, you can ignore leading and trailing zeros, which is why you’ll sometimes see 19, for example, simply as 10011 instead of 00010011. (If that’s confusing, think of it this way: 0019 and 19 have the same value, which is why you can get rid of the extra zeros.) You’ll see how leading and trailing zeros come into play with the next method of conversion…

Method Two: Division

Any decimal number (take 4,673 for example) can be broken into components (4*1000 + 6*100 + 7*10 + 3) by dividing it by 10—the decimal base—over and over and keeping track of the remainders. This conversion method is similar but divides a number by 2, the binary base, and keeps track of the remainders.

1. Make two columns. Put the number you are converting in the left column.

2. Divide that number by 2. Put the remainder in the R column. (Any remainder greater than zero should be rounded up to 1.) Put the answer of the division in next row of the L column, excluding the remainder.

3. Keep going until both the L column and R column entries equal 1.

Here’s what it will look like:

graph-1

The binary representation of the number is the R column, read from the bottom up. So 19 = 10011.

There are a bunch of helpful online calculators for converting decimal and binary numbers. Google it, then use one to check your answers—or just have it do the work for you!

Now roll up your sleeves, ’cause it’s time to make doughnuts.