TheAmerican Standard Code for Information Interchange ASCII, the most com-monly used code for representing alphanumeric data in a computer, uses binary digits to represent the symbols ty
Trang 1Binary Representation of Data
Computers are electromechanical devices made up of electronic switches At the lowest
levels of computation, computers depend on these electronic switches to make decisions
As such, computers react only to electrical impulses These impulses are understood by
the computer as either on or off states (1s or 0s).
Computers work with and store data using electronic switches that are either on or off
Computers can only understand and use data that is in this two-state (binary) format
1 represents an on state, and 0 represents an off state These 1s and 0s represent the
two possible states of an electronic component in a computer These 1s and 0s are
called binary digits or bits.
TheAmerican Standard Code for Information Interchange (ASCII), the most
com-monly used code for representing alphanumeric data in a computer, uses binary digits
to represent the symbols typed on the keyboard When computers send on/off states
over a network, electricity, light, or radio waves represent the 1s and 0s Each
charac-ter has a unique patcharac-tern of eight binary digits assigned to represent the characcharac-ter
Bits, Bytes, and Measurement Terms
Bits are binary digits They are either 0s or 1s In a computer, they are represented by
on/off switches or the presence or absence of electrical charges, light pulses, or radio
waves
For example:
Computers are designed to use groupings of 8 bits This grouping of 8 bits is called a
byte In a computer, 1 byte represents a single addressable storage location These
stor-age locations represent a value or a single character of data, such as an ASCII code
The total number of combinations of the eight switches being turned on and off is 256
to understand when working with computers and networks
Most computer coding schemes use 8 bits to represent each number, letter, or symbol
A series of 8 bits is called a byte; 1 byte represents a single addressable storage location
(see Table 1-2)
Trang 2The following are commonly used computer measurement terms:
binary format in which data is processed, stored, and transmitted by computers
space on a disk or another storage medium, or the amount of data being sent over a network 1 byte equals 8 bits of data
■ Kb (kilobit)—Approximately 1000 bits
■ KB (kilobyte)—Approximately 1000 bytes (1024 bytes exactly)
■ Mb (megabit)—Approximately 1 million bits
■ MB (megabyte)—Approximately 1 million bytes (1,048,576 bytes exactly)
A megabyte is sometimes called a “meg.” The amount of RAM in most PCs is typically measured in MB Large files are often some number of MB in size
■ GB (gigabyte)—Approximately 1 billion bytes A gigabyte is sometimes called a
“gig.” Hard drive capacity on most PCs is typically measured in GB
■ TB (terabyte)—Approximately 1 trillion bytes Hard drive capacity on some high-end computers is measured in TB
■ kbps (kilobits per second)—One thousand bits per second This is a standard measurement of the amount of data transferred over a network connection
■ kBps (kilobytes per second)—One thousand bytes per second This is a standard measurement of the amount of data transferred over a network connection
Table 1-2 Units of Information
* Common or approximate bytes or bits
NOTE
It is common to
con-fuse KB with Kb and
MB with Mb
Remem-ber to do the proper
calculations when
comparing
transmis-sion speeds that are
measured in KB with
those measured in Kb
For example, modem
software usually shows
the connection speed
in kilobits per second
(for example, 45 kbps)
However, popular
browsers display
file-download speeds in
kilobytes per second
This means that with
a 45-kbps
connec-tion, the download
speed would be a
maximum of 5.76
kBps In practice,
this download speed
cannot be reached
because of other
fac-tors that consume
bandwidth at the
same time Also, file
sizes are typically
expressed in bytes,
whereas LAN
band-width and WAN
links are typically
expressed in kilobits
per second (kbps) or
Megabits per second
(Mbps) You must
multiply the number
of bytes in the file by
8 to determine the
amount of bandwidth
consumed in bps.
Trang 3■ Mbps (megabits per second)—One million bits per second This is a standard
measurement of the amount of data transferred over a network connection Basic Ethernet operates at 10 Mbps
■ MBps (megabytes per second)—One million bytes per second This is a standard
measurement of the amount of data transferred over a network connection
■ Gbps (gigabits per second)—One billion bits per second This is a standard
mea-surement of the amount of data transferred over a network connection 10G or
10 Gigabit Ethernet operates at 10 Gbps
■ Tbps (terabits per second)—One trillion bits per second This is a standard
mea-surement of the amount of data transferred over a network connection Some high-speed core Internet routers and switches operate at more than Tbps
■ Hz (hertz)—A unit of frequency It is the rate of change in the state or cycle in a
sound wave, alternating current, or other cyclical waveform It represents one cycle per second
■ MHz (megahertz)—One million cycles per second This is a common
measure-ment of the speed of a processing chip, such as a computer microprocessor Some cordless phones operate in this range (for example, 900 MHz)
■ GHz (gigahertz)—One thousand million, or 1 billion (1,000,000,000), cycles per
second This is a common measurement of the speed of a processing chip, such as
a computer microprocessor Some cordless phones and wireless LANs operate in this range (for example, 802.11b at 2.4 GHz)
Because computers are designed to work with on/off switches, binary digits and binary
numbers are natural to them However, humans use the decimal number system in
their daily lives It is hard to remember the long series of 1s and 0s that computers use
Therefore, the computer’s binary numbers need to be converted to decimal numbers
Sometimes, binary numbers need to be converted to hexadecimal (hex) numbers This
is done because hex numbers can represent a long string of binary digits with just a
few hexadecimal digits This makes it easier to remember and work with the numbers
Base 10 Number System
A number system consists of symbols and rules for using those symbols Many number
systems exist The number system used most frequently is the decimal, or Base10,
number system It is called Base10 because it uses ten symbols These ten symbols are
the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 Combinations of these digits can represent all
possible numeric values, as documented in Table 1-3
NOTE
PC processors are get-ting faster all the time The microprocessors used in PCs in the 1980s typically ran at less than 10 MHz (the original IBM PC was 4.77 MHz) Currently,
PC processors are pushing speeds up to
3 GHz, with faster processors being devel-oped for the future.
Trang 4The decimal number system is based on powers of 10 The value of each column posi-tion from right to left is multiplied by the number 10 (the base number) raised to a power (exponent) The power that 10 is raised to depends on its position to the left
of the decimal point When a decimal number is read from right to left, the first (right-most) position represents 100(1), and the second position represents 101(10∗1 = 10)
many columns the number has
For example:
2134 = (2 ∗ 103) + (1 ∗ 102) + (3 ∗ 101) + (4 ∗ 100) There is a 4 in the ones position, a 3 in the tens position, a 1 in the hundreds position, and a 2 in the thousands position This example seems obvious when the decimal num-ber system is used Seeing exactly how the decimal system works is important, because
it is needed for you to understand two other number systems, binary (Base2) and hexa-decimal (Base16) These systems use the same methods as the hexa-decimal system Human-readable IP addresses are expressed in Base10 (decimal) The IP address 172.16.14.188
is made up of four decimal numbers separated by dots or periods
Base 2 Number System
binary number system uses only two symbols (0 and 1) instead of the ten symbols used
in the decimal, or Base10, number system The position, or place, of each digit repre-sents the number 2 (the base number) raised to a power (exponent) based on its posi-tion (20, 21, 22, 23, 24, and so on), as documented in Table 1-4
Table 1-3 Base 10 Number System
Number of Symbols Ten
Trang 510110 = (1 ∗ 24 = 16) + (0 ∗ 23 = 0) + (1 ∗ 22 = 4) + (1 ∗ 21 = 2) + (0 ∗ 20 = 0)
= (16 + 0 + 4 + 2 + 0) = 22
If the binary number (10110) is read from left to right, there is a 1 in the 16s position,
a 0 in the 8s position, a 1 in the 4s position, a 1 in the 2s position, and a 0 in the 1s
position, which adds up to decimal number 22 Machine-readable IP addresses are
expressed as a string of 32 bits (binary)
Base 16 Number System
The Base16, or hexadecimal (hex), number system is used frequently when working
with computers because it can represent binary numbers in a more readable form The
computer performs computations in binary, but there are several instances in which a
computer’s binary output is expressed in hexadecimal form to make it easier to read
The hexadecimal number system uses 16 symbols Combinations of these symbols can
represent all possible numbers Because only ten symbols represent digits (0, 1, 2, 3, 4,
5, 6, 7, 8, and 9) and because Base16 requires six more symbols, the extra symbols are
the letters A, B, C, D, E, and F The A represents the decimal number 10, B represents
11, C represents 12, D represents 13, E represents 14, and F represents 15, as shown in
Table 1-5
The position of each symbol (digit) in a hex number represents the base number 16
raised to a power (exponent) based on its position Moving from right to left, the first
position represents 160(or 1), the second position represents 161 (or 16), the third
expressed as a string of 12 hexadecimal characters
Table 1-4 Base 2 Number System
Number of Symbols Two
Trang 6= 12) = (65536 + 2560 + 32 + 12) = 68144
Decimal-to-Binary Conversion
You can convert decimal numbers to binary numbers in many different ways The flowchart shown in Figure 1-10 describes one method This process involves trying to figure out which values of the power of 2 are added together to get the decimal num-ber being converted This method is one of several that can be used It is best to select one method and practice with it until it always produces the correct answer
Here’s an example:
These steps convert the decimal number 168 to binary:
Step 1 128 fits into 168, so the leftmost bit in the binary number is a 1
168 – 128 = 40
Step 2 64 does not fit into 40, so the second bit from the left is a 0
Step 3 32 fits into 40, so the third bit from the left is a 1
40 – 32 = 8
Step 4 16 does not fit into 8, so the fourth bit from the left is a 0
Step 5 8 fits into 8, so the fifth bit from the left is a 1
8 – 8 = 0, so the remaining bits to the right are all 0s
Step 6 As a result, the binary equivalent of the decimal value 168 is 10101000 For more practice, try converting decimal 255 to binary The answer should be 11111111
Table 1-5 Base 16 Number System
Number of Symbols 16
Symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Trang 7Figure 1-10 Decimal-to-Binary Conversion Process
Start with Decimal Number
128 Fits into Decimal Number?
64 More Fits?
32 More Fits?
16 More Fits?
8 More Fits?
4 More Fits?
2 More Fits?
1 More Fits?
Conversion Done
Stop
Trang 8This flowchart works for decimal numbers of 255 or less It yields an eight-digit binary number This is appropriate for translating decimal IP addresses Larger numbers can
be converted by starting with the highest power of 2 that fits For example, the number
650 can be converted by first subtracting 512 This yields a ten-digit binary number
Binary-to-Decimal Conversion
As with decimal-to-binary conversion, there is usually more than one way to solve the conversion The flowchart in Figure 1-11 shows one example
Binary numbers can also be converted to decimal numbers by multiplying the binary digits by the base number of the system (Base2) raised to the exponent of its position Here’s an example:
Convert the binary number 01110000 to a decimal number
0∗ 20 = 0 +
0∗ 21 = 0 +
0∗ 22 = 0 +
0∗ 23 = 0 +
1∗ 24 = 16 +
1∗ 25 = 32 +
1∗ 26 = 64 +
0∗ 27 = 0 112 (The sum of the powers of 2 that have a 1 in their position)
Decimal-to-Binary Conversion
In this exercise, you practice converting decimal values to binary values
NOTE
Work from right to
left Remember that
anything raised to the
0 power is 1;
there-fore, 20 = 1.
Trang 9Figure 1-11 Binary-to-Decimal Conversion Process
Start with Binary Number.
Decimal Total = 0
Total Now = Decimal
Stop
128 Bit = 1?
Total = Total + 0 Total = Total + 128
64 Bit = 1?
Total = Total + 0 Total = Total + 64
32 Bit = 1?
Total = Total + 0 Total = Total + 32
16 Bit = 1?
Total = Total + 0 Total = Total + 16
8 Bit = 1?
Total = Total + 0 Total = Total + 8
4 Bit = 1?
Total = Total + 0 Total = Total + 4
2 Bit = 1?
Total = Total + 0 Total = Total + 2
1 Bit = 1?
Total = Total + 0 Total = Total + 1
Trang 10As with the flowchart shown in Figure 1-10, the flowchart shown in Figure 1-11 also works for decimal numbers of 255 or less that start with an eight-digit binary number Larger binary numbers can be converted by increasing the power of 2 for each bit on the right For example, if you have a ten-digit binary number, the tenth digit is worth
512, and the ninth is worth 256 if they are turned on (have a value of 1)
Hexadecimal and Binary Conversion
Converting a hexadecimal number to binary form and vice versa is a common task when dealing with the configuration register in Cisco routers Cisco routers have a configuration register that is 16 bits long That 16-bit binary number can be repre-sented as a four-digit hexadecimal number For example, 0010000100000010 in binary equals 2102 in hex
Ethernet and Token Ring, these addresses are 48 bits, or six octets(one octet is 1 byte) (“Oct” comes from the Greek word for eight.) Because these addresses consist of six distinct octets, they can be expressed as 12 hex numbers instead Every 4 bits is a hex digit (24 = 16), as you will see in Table 1-6 in a moment
Instead of writing 10101010.11110000.11000001.11100010.01110111.01010001 you can write the much-shorter hex equivalent:
AA.F0.C1.E2.77.51
To make handling hex versions of MAC addresses even easier, the dots are placed only after every four hex digits, as in AAF0.C1E2.7751
The most common way for computers and software to express hexadecimal output is
by using 0x in front of the hexadecimal number Thus, whenever you see 0x, you know that the number that follows is a hexadecimal number For example, 0x1234 means
1234 in base 16
Like the binary and decimal number systems, the hexadecimal system is based on the use of symbols, powers, and positions The symbols that hex uses are 0 through 9 and
A through F Table 1-6 shows the binary and decimal equivalents of hex digits
Binary-to-Decimal Conversion
In this exercise, you practice converting binary values to decimal values