# Wikijunior:How Things Work/Binary Numbers

## Contents

#### What is Binary?Edit

We, humans, use 10 different digits — 0 to 9 — to construct any number. For example,

15, 987630, 100, 99, 6 and so on.

This is called the *decimal* number system and has **base 10**, which means that this number system has **10** different digits to construct a number.

But computers do not understand the *decimal* number system. Actually it's not their fault! We humans have created them that way! Unlike humans, the insides of computers know only *2* digits — **0** and **1**, because in the simplest electrical systems, electricity can only be "on" or "off." So, it's called the *binary* number system and has **base 2**. ("Bi" means "2".) All the numbers are constructed with only *2* digits — **0** and **1**. A digit in binary (that's a 0 or a 1) is also called a * bit* – which means

*nary digi*

**bi***.*

**t**Computers use this number system to add, subtract, multiply, divide and do all their other maths. They even save data in the form of bits — well, they group them together into chunks of 8 bits. And don't forget, this chunk of 8 bits is called a **byte**.

This book will teach you how binary works, why computers use it, and how they use it.

#### Why do we use Binary?Edit

In normal maths, we don't use binary. We were taught to use our normal number system. Binary is much easier to do math in than normal numbers because you only are using two symbols — 1 and 0 instead of ten symbols — 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.

With just two symbols, you can count quite high using things that just go "on" or "off", "yes" or "no". For example: How high can you count with your fingers? Most people would say 10. If you count on your fingers with binary you can count to 31 with one hand! With two hands, using binary, you can count up to 1023!

Computers use binary because they can only read and store an on or off charge. So, using 0 as "off" and 1 as "on," we can use numbers in electrical wiring. Think of it as this — if you had one color for every math symbol (0 to 9), you'd have ten colors. That's a lot of colors to memorize, but you have done it anyway. If you were limited to only black and white, you'd only have two colors. It would be so much easier to memorize, but you would need to make a new way of writing down numbers. Binary is just that — a new way to record and use numbers which is true.

#### Binary NotationEdit

In school, you were taught that we have a ones, tens, hundreds columns and so on (they multiply by 10). Binary also has columns, but they aren't ones and tens. The columns in binary are...

Binary | ... | 100 0000 | 10 0000 | 1 0000 | 1000 | 100 | 10 | 1 |
---|---|---|---|---|---|---|---|---|

Base-10* version | ... | 64 | 32 | 16 | 8 | 4 | 2 | 1 |

* *Normal, decimal numbers are called base-10, because there are 10 symbols that we use. Binary is called base-2, because it uses two symbols.*

So what makes binary so easy? The answer lies in how we read the number. If we had the number 52, we have a 2 in the ones column, adding 2 times 1 to the total (2). We have a 5 in the 10s column, multiply that together and get 50, adding that to the total. Our total number is 52, like we expect. In binary, though, this is way simpler if you know how to read it fast.

*How about 3? How do you write the number 3 from the base-10 into a base-2 number? What about the rest?* Let's try writing the normal numbers from 1 to 10 in binary form, shall we?

Base-10 | Binary |
---|---|

1 | 1 |

2 | 10 |

3 | 11 |

4 | 100 |

5 | 101 |

6 | 110 |

7 | 111 |

8 | 1000 |

9 | 1001 |

10 | 1010 |

11 | 1011 |

12 | 1100 |

13 | 1101 |

14 | 1110 |

15 | 1111 |

16 | 10000 |

We said we'd write only the numbers from 1 to 10 into binary numbers, but look at that table! It was so easy, we ended up converting the numbers until 16! But take note of how the binary numbers of *1, 2, 4, 8* and *16* match the previous table above. They match, right?

Base-10 version | Binary |
---|---|

1 | 1 |

2 | 10 |

4 | 100 |

8 | 1000 |

16 | 10000 |

Have you noticed a pattern in writing binary numbers? No? Study the table for 1 to 16 again until you understand why in binary,

*"1 + 1 = 10"*and*"1 + 10 = 11"*

in your own way.

We have been trained to read these base-10 numbers really quickly. Reading binary for humans is slower since we are used to base-10. You are now only just starting to learn how to read base-2, so it will be slow. You will get faster over time!

### Translating to Base-10Edit

The binary number for 52 is 110100. How do you read a binary number?

- You look at the ones column. Since it has a 0 in it, you don't add anything to the total.
- Then you look at the twos column. Nothing, so we move on to the next column.
- We have a 1 in the fours column, so we add 4 to the total (total is 4).
- Skipping the eights column since it has a 0, we have come to a 1 in the sixteens column. We add 16 to the total (total is 20).
- Last, we have a 1 in the thirty-twos column. We add this to our total (total is 52).

We're done! We now have the number 52 as our total. The basics of reading a base-2 number is add each columns value to the total if there is a 1 in it. You don't have to multiply like you do in base-10 to get the total (like the 5 in the tens column from the above base-10 example), which can speed up your reading of base-2 numbers. Let's look at that in a table.

Binary digit | Column | Binary digit's value |
---|---|---|

0 | 1 | 0 |

0 | 2 | 0 |

1 | 4 | 4 |

0 | 8 | 0 |

1 | 16 | 16 |

1 | 32 | 32 |

Total |
52 |

Now let's look at another number.

### Finding a Mystery NumberEdit

The binary number is 1011, but we don't know what it is. Let's go through the column-reading process to find out what the number is.

- The ones column has a 1 in it, so we add 1 x 1 to the total (total is 1).
- The twos column has a 1 in it, so we add 1 x 2 to the total (total is 3).
- The fours column has a 0 in it, so we add 0 x 4 to the total (total is still 3).
- The eights column has a 1 in it, so we add 1 x 8 to the total (total is 11).

We are done, so the total is the answer. The answer is 11! Here are some more numbers for you to work out.

#### MemoryEdit

Computers remember everything in binary. For example, if your name is "GEORGE" then the computer has some special binary word to store your name with only 0s and 1s. This is just like using sign language. Every combination of gestures can mean a special word or number. Exactly in this manner, the computer has a different set of combinations for each letter or digit. A few examples:

- G is stored as "0100 0111"
- E is stored as "0100 0101"

### Bits and BytesEdit

A bit defines a binary (dual) state (On or Off, 0 or 1, True or False) which can not be broken into more smaller units. The name is short for binary digit, like the '1' in the binary number '10' (representing decimal '2') in a similar fashion to how a decimal digit (number that can have 10 distinct values in the default decimal base reference) work, for instance the '9' and '8' that are part of the '98' decimal number.

A byte is eight bits put together or a group of 8 bits. Why eight? It has to do with remembering letters, which you shall read later.