Buscar

CS310-CH21 - APPB - NumberSystems

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você viu 3, do total de 39 páginas

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você viu 6, do total de 39 páginas

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Você viu 9, do total de 39 páginas

Faça como milhares de estudantes: teste grátis o Passei Direto

Esse e outros conteúdos desbloqueados

16 milhões de materiais de várias disciplinas

Impressão de materiais

Agora você pode testar o

Passei Direto grátis

Prévia do material em texto

Number Systems 
Binary, Octal, Decimal, Hexadecimal 
Chaminade University 
Department of Computer Science 
 Prof. Martins 
Computer Organization 
& Architecture 
Created by Authors 
Modified by P. Martins 
2 
Number Systems 
 A number system is a way of counting 
things. It's a way of identifying the 
quantity of something. 
3 
The Decimal Number System 
 Our counting system is based on the 
number 10 (10 fingers). 
 The main principle of the decimal 
system is that 10 is considered as a 
new unit from which point counting 
starts again. Ten tens is again a new 
unit. The multiples of 10 are counted by 
the same systems as 1 to 9. 
4 
The Decimal Number System 
 10 digits: 
 
0 1 2 3 4 5 6 7 8 9 
5 
The Decimal Number System 
(132)10 = 100 + 30 + 2 
 
= 1*102 + 3* 101 + 2 * 100 
6 
The Binary System 
 
“There are 10 types of people 
in the world: those who 
know binary and those who 
do not “ 
7 
Power of the base 
Power of 
the base 
 
 24 
 
23 
 
22 
 
21 
 
 20 
 
value 
 
16 
 
8 
 
4 
 
2 
 
1 
8 
The Binary System 
 Two digits: 
 0, 1 (computers use transistors) 
 Consists of two possible states such as 
On - Off, Yes - No, True - False, 
Zero - Non Zero. 
9 
Counting from 0 to 15 
0 0000 4 0100 8 1000 12 1100 
1 0001 5 0101 9 1001 13 1101 
2 0010 6 0110 10 1010 14 1110 
3 0011 7 0111 11 1011 15 1111 
Decimal Binary 
10 
The Binary Number System 
 (101)2 
 
 = 1 * 22 + 0 * 21 + 1*20 
 
 = 4 + 0 + 1 = (5) 
 
 
 Conversão de binario para decimal 
10 
11 
The Octal Number System 
 The octal, or base 8, number system is 
a common system used with 
computers. Because of its relationship 
with the binary system, it is useful in 
programming some types of computers. 
12 
The Octal Number System 
 Eight digits: 
 
 0,1,2,3,4,5,6,7 
13 
Counting from 0 to 15 
0 0 4 4 8 10 12 14 
1 1 5 5 9 11 13 15 
2 2 6 6 10 12 14 16 
3 3 7 7 11 13 15 17 
Decimal Octal 
14 
The Octal Number System 
 (123)8 = 
 
 1 * 82 + 2 * 81 + 3 * 80 
 
 = 64 + 16 + 3 = (83) decimal 
 
 Conversão octal para decimal 
15 
Power of the base 
Power of 
the base 
 
 84 
 
83 
 
82 
 
81 
 
 80 
 
value 
 
4096 
 
512 
 
64 
 
8 
 
1 
16 
The Hexadecimal System 
 16 digits 
 
 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F 
 
17 
Byte Representation 
 
 
 A byte of memory can store a number 
in the range 00 to FF Hex 
18 
Remarks 
 A single hexadecimal number 
requires 4 units of binary numbers. 
This makes it reasonably easy to 
convert between these two numbering 
systems. E.g. 
 (1)16 = (0001)2 
 (9)16 = (0101)2 
 A = 1010 
19 
Counting from 0 to 15 
0 0 4 4 8 8 12 C 
1 1 5 5 9 9 13 D 
2 2 6 6 10 A 14 E 
3 3 7 7 11 B 15 F 
decimal hexadecimal 
20 
The Hexadecimal System 
 (23A)16 = 
 
 2 * 162 + 3 * 161 + 10 * 160 
 
 = 2 * 256 + 48 + 10 = 512 + 48 + 10 = 
512 + 58 = 
 = (570)10 
 
 Conversão para decimal 
 
 
21 
Power of the base 
Power 
of the 
base 
 
164 
 
163 
 
162 
 
161 
 
 160 
 
value 
 
65536 
 
4096 
 
256 
 
16 
 
1 
22 
MSD and LSD 
 When determining the most and least 
significant digits in an octal number, 
use the same rules that you used with 
the other number systems. The digit 
farthest to the left of the radix point is 
the MSD, and the one farthest right of 
the radix point is the LSD. 
 MSD = Most significant digit 
23 
Converting Decimal to Octal 
Convert 42710 to its Octal equivalent 
 
427/8=> Q=53, R = 3 
53/8 => Q=6, R = 5 6538 
 
6/8 => Q=0, R = 6 
 
Q = Quotient R = Remainder 
24 
Converting Octal do Decimal 
 
 Convert 6538 to its Decimal equivalent 
 
Octal Digits 6 5 3 
 x x x 
Positional Value 82 81 80 
 
Sum over the product 384 + 40 + 3 
 42710 
25 
Converting Octal to Binary 
Convert 2678 to Binary 
 
2 6 7 
 
 
010 110 111 
Octal 3-bit 
Binary 
0 000 
1 001 
2 010 
3 011 
4 100 
5 101 
6 110 
7 111 
26 
Converting Decimal to Hexa 
Convert 83010 to its Hex equivalent 
 
830/16 q =51, r =14 
51 /16 q =3, r =3 
3/16 q =0, r=3 
 
 
 
 
33E16 
27 
Converting Hex to Decimal 
 
Convert 3B4F16 to its Decimal equivalent 
 
Hex digits 3 B 4 F 
 x x x x 
Positional Value 163 162 161 160 
 
Product 12288 + 2816 + 64 + 15 
 
 15,18310 
28 
Converting Binary to Hex 
Convert 10010010011011102 to Hex 
 1001 0010 0110 1110 
 9 2 6 14 (E in Hex) 
 926E16 
0000 = 0 0100 = 4 1000 = 8 1100 = 12 
0001 = 1 0101 = 5 1001 = 9 1101 = 13 
0010 = 2 0110 = 6 1010 = 10 1110 = 14 
0011 = 3 0111 =7 1011 = 11 1111 = 15 
29 
Converting Hex to Octal 
Use an intermediate conversion step: 
 
 Hex Binary Octal 
 or 
 Hex Decimal Octal 
 
 Octal Binary Hex 
 or 
 Octal Decimal Hex 
30 
Convert the following numbers 
 
 (25)10 = ?2 
 
 (110101)2 = ?10 
 
 (13)10 = ?8 
 
 (43)16 = ?10 
 
 (96)10 = ?16 
31 
Answers 
 
 2510 = 110012 
 
 1101012 = 5310 
 
 1310 = 158 
 
 4316 = 6710 
 
 9610 = 6016 
32 
Summary 
Division Algorithm Multiplication Algorithm 
Decimal Binary Binary Decimal 
Decimal Octal Octal Decimal 
Decimal Hex Hex Decimal 
Use “4 bit Substitution Code” for Hex Binary 
Use “3 bit Substitution Code” for Octal Binary 
33 
Appendix - Fractions 
1. Converting binary fractions to decimal 
2. Converting decimal fractions to binary 
3. Converting hexadecimal fractions to 
decimal 
4. Converting decimal fractions to 
hexadecimal 
5. Converting hexadecimal fractions to 
binary 
 
34 
Converting Fractional values 
 Fractional values are represented with 
negative powers of the radix. 
 
 Example: 
 
 1001.101 = 23 + 20 + 2-1 + 2-3 = 
(9.625)10 
35 
Converting binary fractions to 
decimal 
 (10.011)2 = ( ? )10 
 (10)2 = (2)10 
 .011 = 0 * 2-1 + 1 * 2-2 + 1 * 2-3 
 = 0 + 1/4 + 1/8 
 = 0 + 0.25 + 0.125 
 = 0.375 
 Therefore (10.011)2 = (2.375)10 
 
 
36 
Converting decimal fractions 
to binary 
 (3.1875)10 = ( ? )2 
 0.1875 * 2 = 0.3750 
 0.3750 * 2 = 0.7500 
 0.7500 * 2 = 1.5000 
 0.5000 * 2 = 1.0000 
 0.0000* 2 = 0.0000 
 Therefore (3.1875)10 = (11.0011)2 
37 
Converting hexadecimal 
fractions to decimal 
 (C.3)16 = ( ? )10 
 (C)16 = (12)10 
 (0.3)16 = ( ? )10 
 3 * 16-1 = 0.1875 
 
 Therefore, (C.3)16 = (12.1875)10 
 
38 
Converting decimal fractions 
to hexadecimal 
 (15.125)10 = ( ? )16 
 (15)10 = (F)16 
 (0.125)10 = ( ? )16 but 
 (0.125)10 = (.0010)2 = (.2)16 therefore, 
 (15.125)10 = (F.2)16 
 
39 
Converting hexadecimal 
fractions to binary 
 (F.C)16 = ( ? )2 
 (F)16 = (1111)2 
 (.C)16 = ( ? )2 but we know that (C)16 = (1100)2 
 Then (.C)16 = (.1100)2 
 Therefore, (F.C)16 = (1111.1100)2

Outros materiais