Binary Numbers

 

      Greetings. Some of you may wonder why I included a page on binary numbers. Well, do you want to know why? Well, it's because I'm bored. I am on my holidays from university and should be studying, but there is only so much that you can do without your brain going numb. So I decided to teach you about binary numbers instead of drinking.

      Binary numbers are the basic form of numbers that a computer uses to calculate whatever it has to calculate, using just the digits 0 and 1. The numbers we use everyday are made of the ten digits, 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9, and this is called the decimal number system. If we take the decimal number 37, it is easily recognisable to humans, but computers need to convert it to binary first.

      One thing that you should note is that any decimal number, e.g. 43 or 187, can be made up of one of each of numbers that are 2 to the power of anything, e.g. 43 can be made up using the numbers 1, 2, 8 and 32. These numbers are 2 to the power of 0, 2 to the power of 1, 2 to the power of 3 and 2 to the power of 5 (to shorten things, lets have '2 to the power of 4' written as '2~4'). Therefore, the binary number of 43 is 101011. I'll explain in detail how I got this later.

      Lets show how these things can be dealt with now. Lets find the binary number of 183.

 

Table of powers of 2

2~7 2~6 2~5 2~4 2~3 2~2 2~1 2~0
128 64 32 16 8 4 2 1

 

      The first thing to do is to subtract the highest power of 2 away from 183. The highest power below 183 is 128, so 183 - 128 = 55. Again, we subtract the highest power of 2 away from the new number, 55, which is 32, and we are left with 23 (55 - 32 = 23). We repeat this process until we are left with 0.

 

Subtractions taken

183 55 23 7 3 1
128 - 32 - 16 - 4 - 2 - 1 -
  55 23   7 3 1 0

 

      What we do next is make out the tables of powers of 2 again. We take note of the powers of 2 used, and put a 1 in the appropriate slots, and put a 0 in the empty slots.

 

Extended table of powers of 2

2~7 2~6 2~5 2~4 2~3 2~2 2~1 2~0
128 64 32 16 8 4 2 1
1 0 1 1 0 1 1 1

 

      Note the order of the 1's and 0's complete the form 10110111? Well, that's your binary number! Try converting the numbers 27, 72 and 469 to binary and click on the numbers to check if your answer is correct.

      Once you have binary numbers mastered, you can learn about hexadecimal numbers on the next page. First, here is a table on the binary numbers between 0 and 15.

 

2~3 2~2 2~1 2~0 Decimal
0 0 0 0 0
0 0 0 1 1
0 0 1 0 2
0 0 1 1 3
0 1 0 0 4
0 1 0 1 5
0 1 1 0 6
0 1 1 1 7
1 0 0 0 8
1 0 0 1 9
1 0 1 0 10
1 0 1 1 11
1 1 0 0 12
1 1 0 1 13
1 1 1 0 14
1 1 1 1 15

 

      To convert binary back to decimal, its easy. Just take the binary number 1011011010. To convert it back, write out a table  going from right to left, starting with 2~0, 2~1 etc, and place the binary digits under the powers of 2 appropriately. Then, simply write the appropriate value of the power of 2 under each 1 digit, and add them all up.

 

2~9 2~8 2~7 2~6 2~5 2~4 2~3 2~2 2~1 2~0 Powers of 2
1 0 1 1 0 1 1 0 1 0 Binary
512   128 64   16 8   2   = 730

Hexadecimal numbers