CAE - Bits, Bytes, and Binary (Lesson)

Bits, Bytes, and Binary

Introduction

Let's learn how to apply binary math to explore how electrical bits are translated into human language.

Intro to Binary Numbers Video

In this lesson, you will learn how electrical bits are translated into human language. Every digital device has some type of circuit board that acts as a path for electrical signals. The best example is the computer motherboard but every digital device has a circuit board. Smartphones, dishwashers, cars -- you name it!

Binary Numbers 101 Video

Computers contain a large collection of tiny switches called transistors, each of which can be turned ON or OFF. Each flip of the switch to ON or OFF is known as a bit or binary digit. All communications to the computer processor happen through bits.

A bit is a very small thing -- just the ON or OFF state of a switch.  But a lot of bits together make the miracle of computing! You see, computers only understand electrical signals going through their transistors – the bits, 0s, and 1s. When we use only two numbers, ONE and ZERO, it is called the binary number system.

When we combine lots of bits into binary numbers, we can create code that delivers text, videos, applications, and all kinds of other data.

Let’s practice! Use the table below to translate your name into binary code.

Binary Code Table

For example, Mary would be written in binary code as 01101 00001 10010 11001.

Of course, manually translating binary code would be very difficult. For example, did you know that an average iTunes song consists of 32,268,288 bits or a five-minute YouTube video is 93,891,000 bits? That’s a LOT of ON and OFF flips!

Bits, Bytes, and Nibbles

Computers are designed to use groupings of eight bits. This grouping is referred to as a byte. Those eight bits can be any combination of 0s and 1s.

Groupings of Eight Bits Table

In a computer, one byte represents a single addressable storage location. To understand “addressable storage location,” it helps to think of a computer hard drive as a big set of storage cubbies like we use for coats and shoes.  Each cubby would be labeled or “addressed” with a number so we know where we stored our coat. A byte is like a cubby -- it is a location on the hard drive where we can store an 8-bit piece of data and each byte can have an address so we can find that data again. 

By the way, four bits are called a nibble. That is not a commonly used term but it’s a cool thing to know -- and it’s cute!

Computers and humans do not speak the same language, so we had to come up with a way to translate from human language to binary (machine language) and back again. Humans do not know how to communicate in binary so how does the app on your computer screen turn into the bits that computers understand?

Here are the steps:

  • Computer programmers write some code using a language that humans understand. Some computer languages are C++, Java, Python, etc.
  • The computer language includes a compiler that takes that code and converts the instructions into machine language.
  • The machine language is in binary numbers which your computer understands.

All the things we use on our computer, from text to pictures to sounds to games, these all started as code that a human wrote using one of the computer languages. Once we use human language to write the code it has to be compiled into machine language which is in binary.  Now computers can understand!

Using Binary to Create Text on Your Screen

How does a computer recognize what letter you want when you press the letter B on your keyboard, for example? Your operating system includes the ASCII code, pronounced ‘askee’ (you already used it to write your name) which uses binary numbers to represent the keyboard characters. ASCII stands for “American Standard Code for Information Interchange.”

Here is what happens when you press the letter B on your keyboard:

  1. ASCII code on your computer recognizes letter B key as decimal number 66.
  2. The computer translates 66 into the binary number 01000010 as the machine language.

When a user types a character on the keyboard, it is recognized as being mapped to a decimal number which is translated into a binary number.  This is how a computer recognizes each unique character on a keyboard that is sent to the computer so that it can recognize that unique character. Note that the binary code for lower case b is completely different from upper case B because to the computer these two characters have nothing in common!

Decimal System

The decimal number system is a base 10 system because there are 10 possible digits that can be used:

0          1          2          3          4          5          6          7          8          9 

To make numbers larger than 9, we use the position of a digit to determine its value. Each position is a multiple of 10.

For example, here is how we can represent number 7,243:

Representation of 7,243 with decimal system

Binary System

The binary number system is a base 2 because there are 2 possible digits that can be used, 0 or 1. To make numbers larger than 1, we use the position of a digit to determine its value.  Each position is a multiple of 2.

For example, here is how we can represent number 6:

Representation of 6 with binary system

In binary system, 1 = 2 to the 0 power, 2 = 2 to the 1st power, 4 = 2 to the 2nd power, 8 = 2 to the 3rd power, and so on. One difference between decimal and binary is that you have to add up the number across the positions. In the above example, we have a 4 plus a 2 which equals 6.

Let’s revisit the ON and OFF switches we discussed earlier… Remember that a lightbulb ON = a binary 0 and a lightbulb OFF = a binary 1.

Lightbulb On Lightbulb Off Table

Remember, a byte has 8 bits – so binary numbers use these 8 position values. By placing the values into a conversion table, we easily convert from binary to decimal numbers.

Let's Practice Binary to Decimal Video

How do computers translate decimals into binary code? Let’s take a look!

BinaryCodeJoke

Solution:

Decimal 100 = (1 x 100) + (0 x 10) + (0 x 1) = 100

Decimal 100
10000000 1000000 100000 10000 1000 100 10 1
1 0 0
100 0 0

Binary 100 = (1 x 4) + (0 x 2) + (0 x 1) = 4

Binary 100
128 64 32 16 8 4 2 1
1 0 0

4

0

0

Reflection and Wrap-up

Let’s wrap up this lesson! We have learned that computers communicate in binary code, 0s, and 1s, off and on electrical signals via transistors. Each digit in binary code is called a bit. A combination of bits creates a byte. Remember, bit is short for a binary digit, meaning each bit is just one number, 0 or 1. Binary code is also known as machine language.

Even though binary code language is super simple, can you imagine trying to figure out what computers are saying by watching flashing transistors? It may be fun for a few words but we will get tired of that “game” very quickly!

This is why we need to convert binary code (base 2, because we have 0 and 1) to decimal code (base 10, because we have 0-9), which is much easier for us humans to understand. We can also use ASCII code to convert decimal numbers to letters.

[CC BY-NC-SA 4.0 Links to an external site.] UNLESS OTHERWISE NOTED | IMAGES: LICENSED AND USED ACCORDING TO TERMS OF SUBSCRIPTION - INTENDED ONLY FOR USE WITHIN LESSON. Shutterstock; Video 1 courtesy of Pumpkin Programmer, CC-BY; Video 2 courtesy of Bits and Bytes TV0, CC-BY