It’s All 1s and 0s: How Computers Map the Physical World

Jonathan Mines
9 min readMar 1, 2018

--

The number “12" is not the value 12 in a carton of eggs. The word “rock” is not the rock you come across outside. Instead they are merely symbols, created from a collection of other symbols, that represent specific concepts that map well to the world around us. They are tools that give us the ability to break down the world, a mass of matter, into manageable chunks. We use them, not because they are objectively “true”, but because they are useful in meeting our goals given a set of physical restrictions.

In essence, computers use of binary is no more complicated than that. Just another man-made system created to achieve some goal with a certain set of restrictions in mind.

The World According to Denary

Before thinking about how computers use the binary system, it’s helpful to think about why we use the denary system. Our goal is to be able to represent numerical values and communicate those value to others. We can imagine a system in which we had a new character for every number imaginable. For example, 156 would actually be a type of squiggly line with a hook on top, not to be confused with the symbol for 38, which would be represented by a circle with a line across the top. That would be the most efficient way of representing values as you would only ever need one character at a time to represent even the biggest numbers, instead of a chain of characters. But it wouldn’t be the most practical. Imagine a 1st Grade teacher testing her students on the difference between the character representing 1,589 and the character representing 2,000,478 and all the characters in between.

Clearly, there’s a limit to how many characters we want to have availible in our system of representation. So what about the opposite end of the spectrum: a tally system with a single availible character? Sure, that’s possible — now show me 2,000,478 using a base-1 system. Clearly, this is also impractical.

Suddenly, the base-10 system makes sense as not the only availible numerical system, but a good fit given our need for practicality, elegance and efficiency. With only 10 availible characters I can represent the number 2,000,478 easily by multiplying the numerical value of that column by the next power of 10 as demonstrated below:

  • 2 x 10⁶= 2,000,000
  • 0 x 10⁵= 0
  • 0 x 10⁴= 0
  • 0 x 10³= 0
  • 4 x 10² = 400
  • 7 x 10¹ = 70
  • 8 x 10⁰ = 8

SUM = 2,000,478

What a great system of representing values. So why don’t computers use that system?

From Denary to Binary

Electrical currents are either running (open/on) or they’re not (closed/off) meaning we have two value characters availible to us: 1 and 0. Given those restrictions, we can use the same methodolgy we used to choose the base-10 system to find a system of representation that computers can use.With only two states availible to represent different characters the only other alternative to binary would be a tally system. But to represent the value 255 in a tally system we would need 255 digits. That’s 255 “on” transistors to represent a relatively small number. Binary only needs 8 to achieve the same goal.

Here’s how binary does that.

A base 2 system works similarly to the base-10 system but instead of multiplying the value of each column by the next multiple of 2, they’re instead multipled by the next multiple of 2. For example, the binary number 10100 can be translated into a base 10 number by simply adding the calculated values below together:

  • 1 x 2⁴ = 16
  • 0 x 2³ = 0
  • 1 x 2² = 4
  • 0 x 2¹ = 0
  • 0 x 2⁰ = 0

From Bits to Bytes

From here, we can start to build a convention for how to use this numerical system to map the world around us on electrical pulses of on and off. First, let’s give our characters a name: Binary digITs or Bits for short, the smallest unit of data in a computer.

Next we’ll determine how many bits it will take to represent a non-numerical value, like a letter or special character. This process is as contrived as the process of picking a numerical system to represent value. We have certain goals, certain pre-established tools, and a general desire for elegance and efficiency. There are 101 characters on a keyboard, meaning we’ll need to represent 101 in binary as the max value. Turns out 101 in base-10 is the number 01100101 in binary. That’s a baseline requirement of 7 availible transistors if we want to map each key to a specific numerical value. But what if there are other characters we want to represent? With 7, all on, we only represent up to the number 127 in base-10. May as well give us one more bit to work with.

And thus, we have bytes, the baseline unit for measuring data, said to represent at a minimum, a single character. We can now represent the values from 0–255 (00000000–11111111).

As computers can only understand numbers, the American Standard Code for Information Interchange (ASCII) was established to assign each character on the keyboard a specific numerical value as depicted below:

As an example, here’s how you would represent the phrase “Hello World!” in binary:

  • Text: Hello World!
  • ASCII Numbers: 072 101 108 108 111 032 087 111 114 108 100 033
  • Binary: 00110000 00110111 00110010 00100000 00110001 00110000 00110001 00100000 00110001 00110000 00111000 00100000 00110001 00110000 00111000 00100000 00110001 00110001 00110001 00100000 00110000 00110011 00110010 00100000 00110000 00111000 00110111 00100000 00110001 00110001 00110001 00100000 00110001 00110001 00110100 00100000 00110001 00110000 00111000 00100000 00110001 00110000 00110000 00100000 00110000 00110011 00110011

Like text, images also need to be converted into binary. We can represent images in binary by splitting an image up into a grid of pixels and breaking down each pixels color into a combination of 3 colors (red, green, and blue), typically referred to as that pixels RGB value. The max value each of those colors can have individually is 255 and the minimum is 0, meaning, each colors value for each pixel can be represented by 1 byte for a total of 3 bytes per pixel.

As an example, we can represent the shade of the green pixel shown above at location (1,0) in RGB and binary below:

  • RGB Values: (6, 250, 7)
  • Binary: 00000110, 11111010, 00000111

Lastly, we can represent sound data in binary as well using “sampling”. By graphing the sound waves of a recorded sound and noting the values of the waves heights at regular intervals we can then convert those values to binary and then recreate that sound wave using those binary values at a later time.

For example, the sound wave above has a decimal value of 8 at the time interval 1, giving it a byte value of 00001000.

From Binary to Logic

There are many different ways to store binary data including punched cards, magnetized tape, optical discs, etc. All use this convention of representing values in a base-2 system. However, representing the world in binary is only half the battle. The other half is operating on it. Enter bitwise operators.

Bitwise operators operate on individual bits and are the fundamental arithmetic operations that a CPU uses. Each bitwise operator has a set of predetermined rules that produce a certain output given two inputs.

Bitwise operators and their corresponding outputs

You may recognize these tools as ones that are part of a system we’ve been using long before electricity was even discovered: logic. While a bitwise operator may seem foreign, they’re derived from logical operators and like numerical systems we use logical operators as bitwise operators because they serve our purposes efficiently and elegantly given our current physical constraints.

Our goal is to take two different values represented by two possible characters produce a new value according to a set of deterministic rules. You can see how our system of propositional logic translates well into computational logic below:

Think about the AND operator in the context of this sentence: “Bob ate lunch and Bob went to the movies.” If the first statement is true and the second statement is false, then the sentence is false.

T & F = F

But if the first statement is true and the second statement is true then the statement is true.

T & T = T

What about the OR operator: “Bob ate lunch or Bob went to the movies”. If the first statement is true and the second statement is false, the sentence is still true.

T v F = T

But if both are false then the sentence is false.

F v F = F

Now replace the T’s and F’s with 1’s and 0’s and we have the building blocks for manipulating binary to create new strings of binary and therefore new representations of values. We use these bitwise operators in logic gates, electronic switches that use this logic to produce new values. Picture the following scenario:

You need to light up the bottom right LED in a calculator to begin displaying the numbers 0, 1, 3, 4, 5, 6, 7, 8, and 9 but not the number 2. That means the binary numbers 00, 01, 100, 101 110, 111, and 1001 but not 10 need to produce a single ON signal (1). To turn those electric signals into a single ON signal for that LED we can chain 3 OR logic gates and a NOT logic gate together to ensure that those values result in either a 1 or a 0. Below, you can see an example of the number 7 represented in binary (1110) resulting in a single ON signal, which results in the bottom right LED lighting up.

Quantum Computing

The only exception to this rule of representing the world in 1’s and 0’s in computers lies in Quantum computing.

Quantum computing attempts to use the “spooky” nature of sub-atomic particles to represent represent data. Photons, for example, have been shown to exhibit seemingly contradictory behavior, representing multiple states at once. The multi-state behavior gives us extra values to play with besides the typical on/off that we generally get with electric signals. Instead of using a bit to store data, quantum computers use qubits, which can be either a 1 or 0 or both at the same time.

--

--