Linux with Operating System Concepts



Download 5,65 Mb.
Pdf ko'rish
bet248/254
Sana22.07.2022
Hajmi5,65 Mb.
#840170
1   ...   244   245   246   247   248   249   250   251   ...   254
Bog'liq
Linux-with-Operating-System-Concepts-Fox-Richard-CRC-Press-2014

Number
Quotient
Remainder
Explanation
81
40
1
81/2 
=
40 and 1/2
40
20
0
40/2 
=
20 and 0/2
20
10
0
20/2 
=
10 and 0/2
10
5
0
10/2 
=
5 and 0/2
5
2
1
5/2 
=
2 and 1/2
2
1
0
2/2 
=
1 and 0/2
1
0
1
1/2 
=
0 and 1/2


Appendix

637
• Largest power of 2 less than or equal to 3 is 2
• 3 


=
1
• Largest power of 2 less than or equal to 1 is 1
• 1 


=
0
• Done
So we see that 219 is made up of 128, 64, 16, 8, 2, 1, or 219 
=
128 
+
64 
+
16 
+

+

+

=
2
7
+
2
6
+
2
4
+
2
3
+
2
1
+
2
0
, so our binary equivalent has 1s in the 7th, 6th, 4th, 3rd, 1st, and 
0th columns, or 11011011
2
.
• Convert 104 to binary: 104 
=
64 
+
32 
+
8, or 104 
=
2
6
+
2
5
+
2
3
=
01101000
2
.
• Convert 60 to binary: 60 
=
32 
+
16 
+

+
4, or 60 
=
2
5
+
2
4
+
2
3
+
2
2
=
00111100
2
.
• Convert 255 to binary: 255 
=
128 
+
64 
+
32 
+
16 
+

+

+

+

=
2
7
+
2
6
+
2
5
+
2
4
+
2
3
+
2
2
+
2
1
+
2
0
=
11111111
2
.
Notice that 255 is the largest value that we can store in 8 bits. This should make sense 
given that 2
8
=
256. This means that we can store 256 different values in 8 bits. The smallest 
value is 00000000
2
or 0, and the largest value is 11111111
2
or 255. The range 0 to 255 consists 
of 256 numbers.
What if we want to store a number larger than 255? If we only have 8 bits, we cannot do 
so. This is known as an 
overflow
. Alternatively, we can use more memory by placing the 
value into multiple bytes. The word size of the computer is the common size for data stor-
age. Today, most computers have word sizes of 32 or 64 bits. This would allow us to store 
2
32
or 2
64
different values in a word. 2
32
is 2
2
*2
30
=
4*1G 
=
4G (roughly 4 billion). Can you 
figure out what 2
64
is?
Let us assume we can store a number in 16 bits. Try to convert each of the following 
from binary to decimal or decimal to binary. The answers are given; see if you can properly 
compute them.
• 0000111100001111
2
to decimal 
=
3855
• 56313 to binary 
=
1101101111111001
• 1010101010101010
2
to decimal 
=
43690
• 9999 to binary 
=
0010011100001111
• 0101111101010000
2
to decimal 
=
24400
• 44044 to binary 
=
1010110000001100
As a Linux user, you may never need to understand binary. However, network addresses 
consist of binary numbers. Your IP address (version 4) is a collection of 4 bytes, each byte 


638

Appendix
known as an 
octet
. The octets are usually presented to you in decimal. But you may be 
required to know how to convert between binary and decimal.
In addition, netmasks are applied on the binary versions of the IP addresses numbers. 
We explore netmasks in Section A.5. It should be noted that IPv6 addresses are 128 bits 
long and usually displayed using hexadecimal notation. We briefly examine hexadecimal 
and a related representation, octal, in the next section.
Before we conclude this section, notice that we only considered how to store positive 
integers in binary. Recall from earlier that a computer is required to store all kinds of 
data in binary, including strings of characters, sounds, pictures, program instructions, 
and nonpositive integer numbers (negative numbers, fractions, and real numbers). We use 
a representation called two’s complement to store signed numbers (numbers that can be 
either positive or negative) and a variation of scientific notation to store fractional numbers 
as floating point numbers. We will briefly examine character storage (e.g., letters, punctua-
tion marks) and image storage in Section A.4 of this appendix.
A.3 HEXADECIMAL AND OCTAL REPRESENTATIONS
Looking at lengthy strings of binary digits is challenging. A person having to inspect data 
in this form will probably lose their place and have to concentrate carefully on every bit. 
For convenience, we can group bits together and represent them using more readable char-
acters. It is easy to convert binary into either the octal (base 8) or hexadecimal (base 16) 
numbering system. In octal, we have 8 different digits available to us, numbered 0 through 
7. You might notice that the numbers 0 through 7 can all be represented using three binary 
bits (0
8
=
000
2
, 7
8
=
111
2
). Table A.4 provides the octal and binary values for 0–7.
To convert from binary to octal, all we need to do is group our binary number into 
groups of three bits and convert each set of bits into its equivalent octal number. We start 
at the right end of the number and group three bits at a time and convert them. If the left-
most portion of the number consists of fewer than three bits, pad them with leading zeroes.
For instance, the binary number 10111110 would be grouped as 10 111 110 and we would 
add a leading 0 to give us 010 111 110. Now we substitute the octal equivalent of the three-
bit binary number: 010 is 2, 111 is 7, 110 is 6, so 10111110
2
=
276
8
. To convert from octal 
to binary, just replace each octal digit with the three bit binary equivalent. Depending 
upon the size of storage available, add leading 0s as needed. For instance, if we want 
TABLE A.4 
Octal and Binary for the First Seven Values

Download 5,65 Mb.

Do'stlaringiz bilan baham:
1   ...   244   245   246   247   248   249   250   251   ...   254




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish