## Binaries

# What are binaries?

A binary system uses two binary digits (bits) in order to represent different kind of data. The following are all valid binary strings:

**1001**

yxxy

8cc8

yxxy

8cc8

As long as you use only 2 kinds of digits it works out. The idea is that you interpret the sequence of these digits in a way that makes sense. The normal way is to use zero's and ones to create a flow of data that can be interpreted by either man or machine. Computers use this logical system to represent everything in your computer. This article will hopefully shed some light on how to make use of binary digits.

# What do binaries represent?

The confusing part is to understand what binaries mean. Each column in a binary string has a value starting with 1. You count from right to left, so the rightmost digit in the binary string 1001 has the value of 1. After that comes the 2, the 4 and the 8 and so on. This means that a 4-bit string has 4 values; 8, 4, 2 and 1. The picture below is an attempt to explain the logic behind binaries.

As we can see in the picture above the first digit from the left has a value of 8 and the first digit from the right has the value of 1. If we had an 8-bit string it would look like this:

All these values are used when making calculations. You can represent any number with a binary system even though you can only type ones and zeroÂ´s. This is where the column values comes into play. With binaries, you only count the values of the ones, not the zeroes, so if a column has a one, you add that columns value to the sum.

Let's show a couple of examples before it gets too confusing:

## Representing the numbers 1, 3 and 6 with a 4-bit string:

**The Number 1 in binary**

As we can see, the binary code for 1 is 0001. This is logical since we only count the columns that has a value 1, and if we only count the first column (marked with green), we get the sum 1. Let's take number 3 as well:

**The Number 3 in binary**

The green marking shows what columns we count, and the math we get is 2 + 1 which surely equals 3. To make this stick however, we will take one more example:

**The Number 6 in binary**

Here the first column doesn't come into play. We add the columns 4 and 2 to get 6.

Here is a list of number 0 - 15:

Number | Binary |
---|---|

0 | 0000 |

1 | 0001 |

2 | 0010 |

3 | 0011 |

4 | 0100 |

5 | 0101 |

6 | 0110 |

7 | 0111 |

8 | 1000 |

9 | 1001 |

10 | 1010 |

11 | 1011 |

12 | 1100 |

13 | 1101 |

14 | 1110 |

15 | 1111 |

# Different approach

There is also a decimal system to use, just like in other math. A short revisit to school:

123 = (1 * 10^2)+(2*10^1)+(3*10^0)

**EQUALS**

123 = (1 * 100 =

**100**) + (2*10 =

**20**) + (3*1=

**3**)

Remember that 0 is a valid number here.

However, 0 is a positive number, and its negative equivalent is -1, not -0. If we take a decimal number, it might be easier:

893.7642

This number is represented as follows:

893.7642 = (8 * 10^2) + (9 * 10^1) + (3 * 10^0) + (7 * 10^-1) + (6 * 10^-2) + (4 * 10^-3) + (2 * 10^-4)

This picture might explain it better:

As we can see, 0 is actually a positive number here.

## The point of all this

We can show binaries in a similar way by using the number by which they appear in order, like this:

1001 = (1 * 2^3) + (0 * 2^2) + (0 * 2^1) + (1 * 2^0)

Here is a picture that displays the connection between the binaries and the numbers:

And here is a picture that depicts three ways of showing the value 149 in binaries:

That concludes this article that has hopefully shed some light on the subject of binaries. Following this article there will be articles on how to do math with binaries, such as addition and subtraction.

## Article comments

Feel free to comment this article using a facebook profile.

I'm using facebook accounts for identification since even akismet couldn't handle all the spam I receive every day.