3-Dec-09
1
1
Binary
Converting to and from decimal
3-Dec-09
2
2
Decimal
l We normally use the decimal (denary)
system, also called base 10
l There are 10 different symbols (digits)
l 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
l To count higher than nine we re-use the
symbols by putting them in columns
l The value of a symbol depends on its
position
3-Dec-09
3
3
Decimal positions
3528
UnitsTensHundredsThousands
1101001000
Eight thousand two hundred and fifty three
3-Dec-09
4
4
Binary
l Computers use the binary system, also called
base 2
l There are two different symbols (digits)
l 0, 1
l To count higher than one we re-use the
symbols by putting them in columns
l The value of a symbol depends on its
position
3-Dec-09
5
5
Binary positions
1011
UnitsTwosFoursEights
1248
One eight, one four, no twos and one unit
That makes thirteen
3-Dec-09
6
6
Counting in binary and
decimal
1511117111
1411106110
1311015101
1211004100
111011311
101010210
9100111
8100000
3-Dec-09
7
7
Why do computers use
binary?
l Computer components that store or handle
data are often two-state devices
l This is like a switch that can be on or off
l A memory unit could exist in two voltage
states, high or low
l A voltage on a cable could be high or low
l A light could be on or off
l Two states can be coded by binary 0 and 1
3-Dec-09
8
8
Why am I learning about
binary?
l In your Cisco course, you will learn about IP
addresses and how to split up a network into
subnets
l You need to work out subnet addresses and
workstation addresses
l For this you need to use binary
3-Dec-09
9
9
Bytes or octets
l We often handle binary digits (bits) in groups
of eight
l Sometimes these groups are called bytes
l Sometimes they are called octets
l We shall often be calling them octets
l Examples of octets:
00101101
10110010
3-Dec-09
10
10
Convert binary to decimal
Binary
1248163264128Value
Convert 11001010 binary to decimal
Write in the binary digits under their values
3-Dec-09
11
11
Convert binary to decimal
01010011Binary
1248163264128Value
Convert 11001010 binary to decimal
Write in the binary digits under their values
Next write in the value for each binary 1 digit
3-Dec-09
12
12
Convert binary to decimal
2864128
01010011Binary
1248163264128Value
Convert 11001010 binary to decimal
Write in the binary digits under their values
Next write in the value for each binary 1 digit
Add up the values 128 + 64 + 8 + 2 = 202
3-Dec-09
13
13
One for you to try
l Convert 10010101 from binary (base 2) to decimal
(base 10)
Binary
1248163264128Value
3-Dec-09
14
14
Answer
l Convert 10010101 from binary (base 2) to decimal
(base 10)
1416128
10101001Binary
1248163264128Value
128 + 16 + 4 + 1 = 149
3-Dec-09
15
15
Convert 185 decimal to binary
Check
Binary
1248163264128Value
Convert 185 decimal to binary
Can you take 128 from 185? Yes.
Put 1 under 128
What is left? 185-128 = 57
3-Dec-09
16
16
Convert 185 decimal to binary
Check
1Binary
1248163264128Value
We have 57 left
Can you take 64 from 57? No.
Put 0 under 64
What is left? Still 57
3-Dec-09
17
17
Convert 185 decimal to binary
Check
01Binary
1248163264128Value
We have 57 left
Can you take 32 from 57? Yes.
Put 1 under 32
What is left? 57 – 32 = 25
3-Dec-09
18
18
Convert 185 decimal to binary
Check
101Binary
1248163264128Value
We have 25 left
Can you take 16 from 25? Yes.
Put 1 under 16
What is left? 25 – 16 = 9
3-Dec-09
19
19
Convert 185 decimal to binary
Check
1101Binary
1248163264128Value
We have 9 left
Can you take 8 from 9? Yes.
Put 1 under 8
What is left? 9 – 8 = 1
3-Dec-09
20
20
Convert 185 decimal to binary
Check
11101Binary
1248163264128Value
Wwe have 1 left
Can you take 4 from 1? No.
Put 0 under 4
What is left? Still 1
3-Dec-09
21
21
Convert 185 decimal to binary
Check
011101Binary
1248163264128Value
We have 1 left
Can you take 2 from 1? No.
Put 0 under 2
What is left? Still 1
3-Dec-09
22
22
Convert 185 decimal to binary
Check
0011101Binary
1248163264128Value
We have 1 left
Can you take 1 from 1? Yes.
Put 1 under 1
What is left? Nothing. Finished.
3-Dec-09
23
23
Convert 185 decimal to binary
Check
10011101Binary
1248163264128Value
185 decimal is 10111001 binary
3-Dec-09
24
24
Convert decimal to binary
181632128Check
10011101Binary
1248163264128Value
Check: write in the values of the 1 digits and
add them up
128 + 32 + 16 + 8 + 1 = 185
That’s the number we started with. It’s correct.
3-Dec-09
25
25
One for you to try
l Convert 248 from decimal to binary
l Check your answer
Check
Binary
1248163264128Value