Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 27 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
27
Dung lượng
336,98 KB
Nội dung
3-Dec-09
quangkien@gmail.com 1
1
Binary
Converting toandfrom decimal
3-Dec-09
quangkien@gmail.com 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
quangkien@gmail.com 3
3
Decimal positions
3528
UnitsTensHundredsThousands
1101001000
Eight thousand two hundred and fifty three
3-Dec-09
quangkien@gmail.com 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
quangkien@gmail.com 5
5
Binary positions
1011
UnitsTwosFoursEights
1248
One eight, one four, no twos and one unit
That makes thirteen
3-Dec-09
quangkien@gmail.com 6
6
Counting in binaryand
decimal
1511117111
1411106110
1311015101
1211004100
111011311
101010210
9100111
8100000
3-Dec-09
quangkien@gmail.com 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
quangkien@gmail.com 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
quangkien@gmail.com 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
quangkien@gmail.com 10
10
Convert binaryto decimal
Binary
1248163264128Value
Convert 11001010 binaryto decimal
Write in the binary digits under their values
[...]...Convert binarytodecimal Value 128 64 32 16 8 4 2 1 Binary 1 1 0 0 1 0 1 0 Convert 11001010 binarytodecimal Write in the binary digits under their values Next write in the value for each binary 1 digit 3-Dec-09 quangkien@gmail.com 11 11 Convert binarytodecimal Value 128 64 32 16 8 4 2 1 Binary 1 1 0 0 1 0 1 0 128 64 8 2 Convert 11001010 binarytodecimal Write in the binary digits under... 185 decimaltobinary Value 128 64 32 16 8 4 2 1 Binary Check Convert 185 decimaltobinary Can you take 128 from 185? Yes Put 1 under 128 What is left? 185-128 = 57 3-Dec-09 quangkien@gmail.com 15 15 Convert 185 decimaltobinary Value 128 Binary 64 32 16 8 4 2 1 1 Check We have 57 left Can you take 64 from 57? No Put 0 under 64 What is left? Still 57 3-Dec-09 quangkien@gmail.com 16 16 Convert 185 decimal. .. Next write in the value for each binary 1 digit Add up the values 128 + 64 + 8 + 2 = 202 3-Dec-09 quangkien@gmail.com 12 12 One for you to try l Convert 10010101 frombinary (base 2) to decimal (base 10) Value 128 64 32 16 8 4 2 1 Binary 3-Dec-09 quangkien@gmail.com 13 13 Answer l Convert 10010101 frombinary (base 2) to decimal (base 10) Value 128 64 32 16 8 4 2 1 Binary 1 0 0 1 0 1 0 1 128 16 4 1... decimaltobinary Value 128 64 Binary 1 32 16 8 4 2 1 0 Check We have 57 left Can you take 32 from 57? Yes Put 1 under 32 What is left? 57 – 32 = 25 3-Dec-09 quangkien@gmail.com 17 17 Convert 185 decimaltobinary Value 128 64 32 Binary 1 0 16 8 4 2 1 1 Check We have 25 left Can you take 16 from 25? Yes Put 1 under 16 What is left? 25 – 16 = 9 3-Dec-09 quangkien@gmail.com 18 18 Convert 185 decimalto binary. .. 2 from 1? No Put 0 under 2 What is left? Still 1 3-Dec-09 quangkien@gmail.com 21 21 Convert 185 decimaltobinary Value 128 64 32 16 8 4 2 Binary 1 0 1 1 1 0 1 0 Check We have 1 left Can you take 1 from 1? Yes Put 1 under 1 What is left? Nothing Finished 3-Dec-09 quangkien@gmail.com 22 22 Convert 185 decimaltobinary Value 128 64 32 16 8 4 2 1 Binary 1 0 1 1 1 0 0 1 Check 185 decimal is 10111001 binary. .. 32 16 Binary 1 0 1 8 4 2 1 1 Check We have 9 left Can you take 8 from 9? Yes Put 1 under 8 What is left? 9 – 8 = 1 3-Dec-09 quangkien@gmail.com 19 19 Convert 185 decimaltobinary Value 128 64 32 16 8 Binary 1 0 1 1 4 2 1 1 Check Wwe have 1 left Can you take 4 from 1? No Put 0 under 4 What is left? Still 1 3-Dec-09 quangkien@gmail.com 20 20 Convert 185 decimaltobinary Value 128 64 32 16 8 4 Binary. .. quangkien@gmail.com 23 23 Convert decimaltobinary Value 128 64 32 16 8 4 2 1 Binary 1 0 1 1 1 0 0 1 Check 128 32 16 8 1 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 quangkien@gmail.com 24 24 One for you to try l l Convert 248 from decimal tobinary Check your answer Value Binary 128 64 32 16 8 4 2 1 Check... 24 One for you to try l l Convert 248 from decimal tobinary Check your answer Value Binary 128 64 32 16 8 4 2 1 Check 3-Dec-09 quangkien@gmail.com 25 25 Answer l l Convert 248 from decimal tobinary Check your answer Value Binary 128 1 64 1 32 1 16 1 8 1 Check 126 64 32 16 4 0 2 0 1 0 8 128 + 64 + 32 + 16 + 8 = 248 So 11111000 is correct 3-Dec-09 quangkien@gmail.com 26 26 End 3-Dec-09 quangkien@gmail.com . 10 10 Convert binary to decimal Binary 1248163264128Value Convert 11001010 binary to decimal Write in the binary digits under their values 3-Dec-09 quangkien@gmail.com 11 11 Convert binary to decimal 0101001 1Binary 1248163264128Value Convert. for you to try l Convert 10010101 from binary (base 2) to decimal (base 10) Binary 1248163264128Value 3-Dec-09 quangkien@gmail.com 14 14 Answer l Convert 10010101 from binary (base 2) to decimal. 12 12 Convert binary to decimal 2864128 0101001 1Binary 1248163264128Value Convert 11001010 binary to decimal Write in the binary digits under their values Next write in the value for each binary 1