Binary Numbers

02

There are only 10 types of people in the world. 

Those who understand binary and those who don't.

One of the important principles of computer science is that computers use binary sequences: i.e., sequences of 0s and 1s, to represent all data. That means our photographs, videos, text messages, mobile apps, Word documents, and numerical quantities are all represented as sequences of bits.

In this unit we want to focus on the binary number system: i.e., using sequences of 0s and 1s to represent numbers. The binary number system is very similar to our decimal number system. But whereas the decimal system uses ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, to represent numbers, the binary system uses only two digits: 0 and 1.

The reason computers use the binary system is because its two digits, 0 and 1, are easily represented in electronic devices, where the 0 could be represented by "off" and the 1 by "on". Or the 0 could be represented by low voltage and the 1 by high voltage. A bit is the smallest unit of binary information. A bit can be either 0 or 1. So, in one sense, because it uses only 2 digits, whereas the decimal system uses ten digits, the binary number system is even simpler that our decimal system. 

Amazingly, by combining 0s and 1s in various combinations, we can represent all of the data and information that computers use and process. 

Technical Terminology

Binary Intro - Video

Binary Intro - Slides

D01-Binary Numbers A

Converting Binary to Decimal 

As you saw in the video, the binary number system is a positional number system The value of a particular digit depends on its place

The place values for the binary system are the 1s place, the 2s place, the 4s place, the 8s place, the 16s place, and so on (powers of two). Contrast that with the place values for the decimal system: the 1s place, the 10s, place, the 100s place, and so on (powers of ten).

To figure out the decimal value of a binary number, we add up the powers of two of all the places that contain a 1

Binary To Decimal - Video

Binary To Decimal - Slides

D01-Binary Numbers B - Converting Binary to Decimal

Converting Decimal to Binary 

You can a similar algorithm to convert decimal numbers into binary. For example, here's the algorithm as applied to the decimal number 25:

Binary To Decimal - Video

Binary To Decimal - Slides

D01-Binary Numbers C - Converting Decimal to Binary

Still Curious?

Adding in binary has the same carry rules as normal adding in decimal, except that the carry is for each power of two and not power of ten. See an example to the right.

One problem with binary numbers is that it takes lots of digits to represent relatively small numbers. For example, a number like 1 million, which really isn’t very big these days,  would requires 20 binary digits: 11110100001001000000

There are lots of online video lessons about number systems. You can search for "binary numbers" or "hexadecimal numbers" or "number systems". Here's a Khan Academy video on binary numbers. 

Going even further: each character representing letters etc. are given a number in ASCII and Unicode, and these numbers can be converted into binary and used in computers