Edited Mr. D.
Watkis
What is a binary number?
A binary number is a number that includes
only ones and zeroes.
The number could be of any length
The following are all examples of binary
numbers
0 10101
1 0101010
10
1011110101
01
0110101110
111000 000111
Another name for binary is base-2
(pronounced "base two")
What is a decimal
number?
The numbers that we are used to seeing are
called decimal numbers.
decimal numbers consist of the digits from 0
(zero) through 9.
The following are examples of decimal #'s
3
15
890
76
32423234
53
Another name for decimal numbers are base-
10 (pronounced "base ten") numbers.
Equivalence of Binary and
Decimal
Every Binary number has a corresponding
Decimal value (and vice versa)
Examples:
Binary Number Decimal Equivalent
11
10
2
11
3
1010111
87
4
The value of a binary
number
Even though they look exactly the same, the
value of the binary number, 101, is different
from the value of the decimal number, 101.
The value of the binary number, 101, is equal to
the decimal number five (i.e. 5)
The value of the decimal number, 101, is equal to
one hundred and one
When you see a number that consists of only
ones and zeroes, you must be told if it is a
binary number or a decimal number.
5
All information on computers is
stored as numbers
All information that is processed by computers is
converted in one way or another into a sequence of
numbers. This includes
numeric information
textual information and
Pictures
(Well see later how text and pictures can be converted
into simple numbers for now just take our word for it.)
Therefore, if we can derive a way to store and retrieve
numbers electronically this method can be used by
computers to store and retrieve any type of
information.
How does a CD store
information?
For detailed information about a CD works,
see the following URL:
http://electronics.howstuffworks.com/cd.htm
This presentation will only focus on the very
basics.
Information is stored using binary
numbers
A binary number is simply a bunch of 1s and
0s
CDs that are created in a factory (were not
talking about CD-Rs yet) may look perfectly
flat. However, there are many microscopic
bumps on the surface of the CD.
The bumps are laid out in a spiral form on the
surface of the CD.
Converting from binary to
decimal
Each position for a binary number has a value.
For each digit, multiply the digit by its position
value
Add up all of the products to get the final result
The decimal value of binary 101 is computed
below:
4
2
1
--------------------------------------
1X1
0X2
1X4
---5
=1
=4
=0
11
What about a longer
number?
In general, the "position values" in a
binary number are the powers of two.
The
The
The
The
The
etc.
first position value is 20
2nd position value is 21
2nd position value is 22
2nd position value is 23
2nd position value is 24
,
,
,
,
,
i.e.
i.e.
i.e.
i.e.
i.e.
one
two
four
eight
sixteen
Example on next slide
12
Example
The value of binary 01100001 is decimal 105. This is
worked out below:
128
64
32
16
8
4
2
1
----------------------------------------------------------------------
01
1X1
0X2
0X4
1X8
0 X 16
1 X 32
1 X 64
0 X 128
---Answer:
=1
=
=
=
=
=
=
0
8
0
32
64
0
=0
105
13
Another example
The value of binary 10011100 is decimal 156. This is
worked out below:
128
64
32
16
8
4
2
1
----------------------------------------------------------------------
10
0X1
0X2
1X4
1X8
1 X 16
0 X 32
0 X 64
1 X 128
---Answer:
=0
=
=
=
=
=
=
4
8
16
0
0
128
=0
156
14
Some Terminology
The following are some terms that are used in
the computer field
Each digit of a binary number is called a bit.
A binary number with eight bits (i.e. digits) is
called a byte.
15
How many different
numbers?
There are two different binary numbers with one
bit:
0
1
There are four different binary numbers with two
bits:
00
01
10
11
(i.e.
(i.e.
(i.e.
(i.e.
decimal
decimal
decimal
decimal
0)
1)
2)
3)
16
How many different
numbers?
There are eight different binary numbers with
three bits:
000
001
010
011
100
101
110
111
(i.e.
(i.e.
(i.e.
(i.e.
(i.e.
(i.e.
(i.e.
decimal 0)
decimal 1)
decimal 2)
decimal 3)
decimal 4)
decimal 5)
decimal 6)
(i.e. decimal 7)
17
# different
numbers
- numbers:
n bits there are
2 different binary
General
Rule
# of bits # of different binary numbers
For
1 bit:
2 bits:
3 bits:
4 bits:
5 bits:
6 bits:
7 bits:
8 bits:
9 bits:
10 bits:
etc.
21 = 2
22 = 4
23 = 8
24 = 16
25 = 32
26 = 64
27 = 128
28 = 256
29 = 512
210 = 1024
18
Largest value for a binary
#
The largest value for a binary number with a
specific number of bits (i.e. digits) is when all
of the bits are one.
General rule: for a binary number with n bits,
the largest possible value is : 2n - 1
19
Largest numbers
The following are the largest values for binary
numbers with a specific number of bits:
# of bits
1 bit:
2 bits:
3 bits:
4 bits:
5 bits:
6 bits:
7 bits:
8 bits:
etc.
largest binary # decimal value
1
1
11
3
111 7
1111 15
1111131
111111
1111111
11111111
63
127
255
20
Converting a decimal# to a
binary#
(1)
To convert the decimal number 20 to binary:
Step 1: Divide it by two and record the remainder
Step 2: Divide the previous answer by two and again
record the remainder
Step 3: Continue this process till you reach the
number 1.
Step 4: 1 cannot be divided into 2 and return a whole
number so the write down 0 (zero) and carry down 1
in the remainder.
21
Why is it called "binary" (or
base-2)?
The prefix "bi" means "two" in Latin
Binary derives its name from the fact that the
digits in a "Binary" number can only have two
possible values, 0 or 1
It is also called "base-2" based on the fact
that the column values are the powers of 2.
(i.e. 20 21 22 23 24 25 etc. )
22
Converting a decimal# to a
binary#
(2)
Convert the decimal # 20 to binary
2
20
10
Writing down the remainder from bottom to
top. Answer = 10100
23