Uploaded by ahmedbosofa1997

IntroductiontoBinarywithNetworking-1

advertisement
INTRODUCTION TO BINARY
WHAT IT IS AND HOW IT IS USED FOR CISCO NETWORKING
OUTLINE
 What is binary?
 How is it used for CISCO networking?
 Translating Binary to Decimal
 Translating Decimal to Binary
WHAT IS BINARY?
 Binary is the language that computers and electronics use to communicate and send data
 Binary is a series of 1s and 0s – typically indicating a state of on (1) or a state of off (0)
 Positional notation refers to the fact that each 1 or 0 in a specific location refers to a specific value – for example,
the number 0010 = 2, because the 1 is in the position for the value of 2
HOW IS IT USED FOR CISCO NETWORKING
 CISCO networking, and any networking that utilizes the TCP/IP protocol suite, uses binary to denote IP
addresses. While most of the time one will see these addresses in decimal format (for example 192.168.2.1),
binary is actually used to create addresses and subnetworks.
 A typical IP address consists of 4 octets – each octet is 8 binary numbers long – for example, the first octet, 192,
in the address above would translate to 01100000 in binary. Notice that it is 8 characters long.
TRANSLATING BINARY TO DECIMAL
 Binary is based on a power of 2 system – i.e. each position in a binary number is the next power of 2 – for
example:
2^7
2^6
2^5
2^4
2^3
2^2
2^1
2^0
128
64
32
16
8
4
2
1
Position 8
Position 1
TRANSLATING BINARY TO DECIMAL
 To translate a binary number to a decimal number, use the positional table – for example, translate the number
00110100 to binary:
2^7
2^6
2^5
2^4
2^3
2^2
2^1
2^0
128
64
32
16
8
4
2
1
0
0
1
1
0
1
0
0
Next, add all of the numbers that have a 1 together
32 + 16 +4 = 52
First, place
the binary
number in
the chart
NOW YOU TRY!
Convert 01110011 to decimal using the table:
2^7
2^6
2^5
2^4
2^3
2^2
2^1
2^0
128
64
32
16
8
4
2
1
0
1
1
1
0
0
1
1
Answer:
64+32+16+2+1 =115
TRANSLATING DECIMAL TO BINARY
 There are two methods for converting decimal to binary
 They are Least Significant Digit (LSD) and Most Significant Digit (MSD)
 MSD is the most common method and the method that CISCO tends to teach
TRANSLATING DECIMAL TO BINARY
Most Significant Digit Method (MSD)
 Starts at the highest Binary value (for networking, this is
128)
 Step 1: Compare the value of the number to the highest
value, if the value is equal to or greater than this value, a 1
is placed in the number and the binary value is subtracted
from the decimal value (otherwise, skip to step 2)– for
example:
156 is the value to translate
is 156 >= 128?
YES!
So, a 1 is placed in the value for 128 and 128 is
taken from 156
156- 128 = 28
2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
128
1
64
32
16
8
4
2
1
TRANSLATING BINARY TO DECIMAL
 Step 2: Using your remainder of 28 from Step
1, continue to compare it to the other values
until you find one it is equal to or greater than
– once you have found that value, do the same
thing you did in step 1 and add a 1 to the
value and subtract it from the decimal value
 Step 3: Continue this process until you reach
0
 End: Once you reach 0 you are done – if
there are any remaining values, fill them with
0s
28 >= 64? NO (place a 0)
28 >= 32? NO (place a 0)
28 >= 16? Yes!!! (Place a 1 and subtract)
28-16 = 12
12 >= 8? Yes!!! (Place a 1 and subtract)
12- 8 = 4
4 >= 4? Yes!!! (Place a 1 and subtract)
4-4 = 0
Stop!! You have reached 0! Fill any remaining
values with 0s
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
0
1
1
1
0
0
Binary: 10011100
NOW YOU TRY!
Convert 122 to binary using the MSD method:
Answer:
122 >= 128? NO! (Place a 0)
122 >= 64? Yes!!! (Place a 1 and subtract)
122-64 = 58
2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
128
64
32
16
8
4
2
1
58 >= 32? Yes!!! (Place a 1 and subtract)
58-32 = 26
26 >= 16? Yes!!! (Place a 1 and subtract)
26-16 = 10
10 >= 8? Yes!!! (Place a 1 and subtract)
10 – 8 = 2
2 >= 4? NO! (Place a 0)
2 >= 2? Yes!!! (Place a 1 and subtract)
2-2 = 0
STOP!!! You have reached 0 – fill in remaining values with 0s
2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0
128
64
32
16
8
4
2
1
0
1
1
1
1
0
1
0
Binary: 01111010
TRANSLATING BINARY TO DECIMAL
Least Significant Digit (LSD) Method
 Uses Division to calculate the number
 Starts at the smallest value (1) and progresses to the largest (128 for networking
purposes)
 N represents the decimal number, Q the result of the division, R the remainder of the
number, and B the binary value:

Step 1: Divide N by 2, if there is a remainder, place a 1, if not, place a 0


For example:
N
Q
R
B
122
61
0
0
In this example, the division by 2 leaves no remainder, so the binary value is 0
TRANSLATING BINARY TO DECIMAL
 Step 2: continue this process, substituting Q for N in each step – for example:
N (Value)
Q (Result of /2)
Remainder
Binary
Value
122
61
0
0
61
30
1
1
30
15
0
0
15
7
1
1
7
3
1
1
3
1
1
1
1
0
1
1
0
0
0
0
Step 3: Stop when you hit 0
Step 4: Starting at the bottom,
write out the binary number
= 01111010
NOW YOU TRY!
 Convert 115 to Binary from Decimal using the LSD Method
Answer:
N (Value)
Q (Result of /2)
Remainder
Binary
Value
115
57
1
1
57
28
1
1
28
14
0
0
14
7
0
0
7
3
1
1
3
1
1
1
1
0
1
1
0
0
0
0
= 01110011
CHECKING YOUR WORK
 There are binary calculators available for use that can easily help you
translate between binary and decimal as well as act as a method of
checking your work. The built in calculator for Windows is one of
these.
Windows Calculator:
 In the calculator, go to View  Programmer to switch to programmer
mode
 To convert decimal to binary, make sure that the type is selected to
Dec on the left, type in your number, then change the type to Bin to
translate to binary
 To convert binary to decimal, make sure that the type is selected to
Bin, then type in your number, then change the type to Dec to
translate to decimal
Type Selection
SUMMARY
 Binary is used in Networking for addressing
 Binary can be converted to decimal and decimal can be converted to binary using several different methods
 Always check your work – you can use the built-in Windows Calculator to do so, or there are several others
available online
Download