Intro to Binary Numbers

October 3rd, 2014


There are 10 kinds of people in the world: those who understand binary and those who dont.
someone clever

Binary numbers are at the heart of how computers work. Understanding this code may seem cryptic to the uninitiated, but its fairly simple. Actually, its ridiculously simple. With just two little numbers, computers somehow create colors, sounds, text, and more. Since the advent of digital technology, binary numbers have become essential to our daily lives. Little do we know that these strings of ones and zeros comprise some of our most precious information and interactions in the world. Therefore, its well worth our while to have at least a basic understanding of how these infamous ones and zeros work. In this tutorial, I hope to make binary understandable to just about anyone, whether you are young, tech-savvy or not.

Lets Get Digital!

The smallest unit of data a computer can represent is the bit. The word bit is short for binary digit. Like a light bulb, a bit can be one of two states: ON or OFF. In computing, a bit represents a single ON or OFF signal in an electrical circuit. These ON-OFF values are represented by the numbers 1 and zero respectively.

From these simple bits, computers string together large sequences of ones and zeros to represent complex data and instructions. A string of 8 bits is referred to as a byte. Byte is short for binary term.

Since these ON-OFF signals are composed of finite states, we call them digital. By contrast, an analog signal would cover a range of virtually infinite points. Visually, we could represent digital signals as step functions and analog signals as continuous waves. For example, in a digital computer, we can represent music as a series of bits in an MP3 file. In an analog system, we can represent music as a pattern of waves. Old-fashioned vinyl records are a good example of an analog recording medium. Rather than represent music through a series of bits, the grooves in vinyl record approximate the actual sound waves that have been recorded.

So now that we know what bits are, let’s learn how such a simple system can store such a wide array of information. We will learn how to represent virtually any number using just ones and zeros.

1, 2, 3,

Let’s use light bulbs to represent bits. Suppose we have an array of four light bulbs. When a light bulb is on, we can represent that “on” state as the digit 1. Conversely, we can represent the “off” state as the digit 0.

Suppose each bulb represents a power of two when turned on. The rightmost bulb represents 2 to the power of 0 (which evaluates to 1). The next bulb over represents 2 to the power of 1 (which evaluates to 2). The next bulb after that represents 2 to the power of 2 (which evaluates to 4). And finally, the leftmost bit represents 2 to power of 3 (which evaluates to is 8).

Below is a table for how to count from zero to fifteen in binary:

Decimal Value Binary Value Binary-to-Decimal Conversion
zero (0) 0000 [0 * (2^3)] + [0 * (2^2)] + [0 * (2^1)] + [0 * (2^0)] =
(0 * 8) + (0 * 4) + (0 * 2) + (0 * 1) =
0
one (1) 0001 [0 * (2^3)] + [0 * (2^2)] + [0 * (2^1)] + [1 * (2^0)] =
(0 * 8) + (0 * 4) + (0 * 2) + (1 * 1) =
1
two (2) 0010 [0 * (2^3)] + [0 * (2^2)] + [1 * (2^1)] + [0 * (2^0)] =
(0 * 8) + (0 * 4) + (1 * 2) + (0 * 1) =
2
three (3) 0011 [0 * (2^3)] + [0 * (2^2)] + [1 * (2^1)] + [1 * (2^0)] =
(0 * 8) + (0 * 4) + (1 * 2) + (1 * 1) =
3
four (4) 0100 [0 * (2^3)] + [1 * (2^2)] + [0 * (2^1)] + [0 * (2^0)] =
(0 * 8) + (1 * 4) + (0 * 2) + (0 * 1) =
4
five (5) 0101 [0 * (2^3)] + [1 * (2^2)] + [0 * (2^1)] + [1 * (2^0)] =
(0 * 8) + (1 * 4) + (0 * 2) + (1 * 1) =
5
six (6) 0110 [0 * (2^3)] + [1 * (2^2)] + [1 * (2^1)] + [0 * (2^0)] =
(0 * 8) + (1 * 4) + (1 * 2) + (0 * 1) =
6
seven (7) 0111 [0 * (2^3)] + [1 * (2^2)] + [1 * (2^1)] + [1 * (2^0)] =
(0 * 8) + (1 * 4) + (1 * 2) + (1 * 1) =
7
eight (8) 1000 [1 * (2^3)] + [0 * (2^2)] + [0 * (2^1)] + [0 * (2^0)] =
(1 * 8) + (0 * 4) + (0 * 2) + (0 * 1) =
8
nine (9) 1001 [1 * (2^3)] + [0 * (2^2)] + [0 * (2^1)] + [1 * (2^0)] =
(1 * 8) + (0 * 4) + (0 * 2) + (1 * 1) =
9
ten (10) 1010 [1 * (2^3)] + [0 * (2^2)] + [1 * (2^1)] + [0 * (2^0)] =
(1 * 8) + (0 * 4) + (1 * 2) + (0 * 1) =
10
eleven (11) 1011 [1 * (2^3)] + [0 * (2^2)] + [1 * (2^1)] + [1 * (2^0)] =
(1 * 8) + (0 * 4) + (1 * 2) + (1 * 1) =
11
twelve (12) 1100 [1 * (2^3)] + [1 * (2^2)] + [0 * (2^1)] + [0 * (2^0)] =
(1 * 8) + (1 * 4) + (0 * 2) + (0 * 1) =
12
thirteen (13) 1101 [1 * (2^3)] + [1 * (2^2)] + [0 * (2^1)] + [1 * (2^0)] =
(1 * 8) + (1 * 4) + (0 * 2) + (1 * 1) =
13
fourteen (14) 1110 [1 * (2^3)] + [1 * (2^2)] + [1 * (2^1)] + [0 * (2^0)] =
(1 * 8) + (1 * 4) + (1 * 2) + (0 * 1) =
14
fifteen (15) 1111 [1 * (2^3)] + [1 * (2^2)] + [1 * (2^1)] + [1 * (2^0)] =
(1 * 8) + (1 * 4) + (1 * 2) + (1 * 1) =
15

Exponential Growth

As you go through the binary-to-decimal conversions in the table above, you may notice a relationship between the number of bits and the number of values that can be represented. As a general rule, X number of bits can represent a total of 2 to the X different values.

As you can see, the number of values that can be represented by X bits is an exponential function, namely 2 to the X power. This is why we can represent such a vast array of information on a computer using simple ones and zeros. It’s pretty magical if you think about it.

Resources

For more information on binary numbers, check out the links resources below. When I was first learning to count in binary, I found the Computer Science Unplugged videos immensely useful.


Categories: mathtutorials