Binary numbers
Introduction
- The smallest and most basic data item in a computer is called a
bit. Physically a bit is really a
switch that can be open or closed. By convention the open position is
represented with a 0 and the closed position is represented with a 1.
- One byte equals 8 bits.
A byte is a fundamental storage unit on most computers.
- Data and instructions are represented electronically inside of a computer
using the binary system.
Place value
Recall the decimal number system uses the ten digits 0,1,2,3,4,5,6,7,8 and 9.
For numbers 10 and greater we must use more digits and the concept of place
value as shown in the example below.
Example:
637 = 6*100 + 3*10 + 7*1 = 6*102 + 3*101 + 7*100
The binary number system uses only the two digits 0 and 1. The place
values for the binary number system are powers of 2 as shown in the following
table.
32 |
16 |
8 |
4 |
2 |
1 |
25 |
24 |
23 |
22 |
21 |
20 |
Binary to decimal conversion
To convert from binary to decimal is easy if you refer to the place values
for each binary digit.
Example: Convert 101101 to a decimal.
32 |
16 |
8 |
4 |
2 |
1 |
1 |
0 |
1 |
1 |
0 |
1 |
32 + 8 + 4 + 1 = 45
Decimal to binary conversion
To convert from decimal to binary we must again use the place values for each
binary digit and use a subtraction process to determine which place values are
0's and which place values are 1's.
Example: Convert 155 to a binary number.
128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
1 |
0 |
0 |
1 |
1 |
0 |
1 |
1 |
- Since we need 128, we place a 1 in this location.
- Since 155 - 128 = 27, we must choose the remaining digits to yield 27.
- We cannot use 64 or 32, so we place 0's in these positions.
- We can use the 16, so we place a 1 in this position.
- Since 27 - 16 = 11, we must choose the remaining digits to yield 11.
- We can use an 8, so we place a 1 in this position.
- Since 11 - 8 = 3, we must choose the remaining digits to yield a 3.
- We cannot use the 4 so we place a 0 in this position.
- We use the 2 and the 1, so we place 1's in these positions.
Internet resources
Number
conversion calculator