Binary Numbering System

Understanding binary numbers will help you understand ASCII code, the bitwise logic in the next lesson, and the fundamental workings of computers.

In elementary school you learned about the decimal numbering system and about the one's place the ten's place, the hundered,s place and the thousand's place. In the Decimal Numbering System we use ten digits (0-9) and after you get to the last digit in the one's place (9) if you add 1 to it you get ten(10), and when you add 1 to 99 you get one hundred(100). In the decimal system, as you move through the places from right to left, the power ten is raised to, increases by one.

Decimal System
Places10x10x1010x10101
Decimal Numbering5932
Decimal5,932


In the binary numbering system we use only two digits (0-1). Instead of the one's place the ten's place, the hundered,s place and the thousand's place, the binary system has the one's place, the two's place, the four's place, and so on. In the binary system, as you move through the places from right to left, the power two is raised to, increases by one. Study the table below.

Binary System
1011 (eleven)
Places2x2x22x221
Binary Digits1011
A Binary Number1011
Calculate Decimal1x80x41x21x1
Decimal8+0+2+1 = 11


Counting is done as below:
binarydecimal equivalentnotes
0 0
1 1
10 2carry 1 to left
11 3
100 4 carry 1 to left
101 5
110 6 carry 1 to left
111 7

In the computer the binary digits are held in bits as either On (1) or Off (0). Eight bits compose the basic unit of computer memory called a byte. The values represented by each bit are as follows:

bit
8
bit
7
bit
6
bit
5
bit
4
bit
3
bit
2
bit
1
1286432168 4 21's

The highest value that a byte can hold is 255 since 128+64+32+16+4+2+1 equals 225. In binary 225 is written 1111 1111. When dealing with computers and programming, always start counting from zero. Therefore any byte can hold any one of 256 values from 0 (0000 0000) to 255 (1111 1111).

Converting from Binary to Decimal


Converting from Binary to Decimal
Places1286432168421
Binary0101 1011
Bits 0x1281x640x321x161x80x41x21x1
Decimal64 + 16 + 8 + 2 + 1 = 91



Converting from Decimal to Binary


You should be able to convert decimal numbers from 1 to 255 into binary. Use the method below if you don't know how.
The simplest way to convert decimal numbers to binary is to repeatedly divide by two, with the remainder each time becoming a binary digit and the result becoming the next number to divide.

For example the decimal number of 57.

57/2=28 and its remainder is 1
28/2=14 and its remainder is 0
14/2=7 and its remainder is 0
7/2=3 and its remainder is 1
3/2=1 and its remainder is 1
1/2=0 and its remainder is 1

Now we take the numbers from the bottom up to form the binary number which is 111001

Assignment #5
Practice converting random numbers between 0 and 255 to binary. Keep practicing until you are sure you have the hang of it. This is important. When you are sure you have it, go on to