Baixe o app para aproveitar ainda mais
Prévia do material em texto
ORGANIZAÇÃO DE COMPUTADORES Aula 2- Sistemas de Numeração AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES ESTRUTURA DA DISCIPLINA AULA 1 – Fundamentos AULA 2 – Sistemas de Numeração AULA 3 – Representação de dados AULA 4 – Lógica Digital AULA 5 – Álgebra Booleana AULA 6 – Modelo de Von Neumann AULA 7 – Conjunto de Instruções AULA 8 – Processador AULA 9 – Memória AULA 10 – Dispositivos de Entrada e Saída AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES Conteúdo Programático AULA 3 Conversão de base Representação de números negativos Representação de caracteres AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES COMO CONVERTER ENTRE AS BASES? Decimal Binário Decimal Hexadecimal Binário Hexadecimal Hexadecimal Binário AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES Decimal Binário REGRA: 1) Realizar divisões sucessivas por 2 enquanto quociente zero 451 |_2_ 1 225 |_2_ 1 112 |_2_ 0 56 |_2_ 0 28 |_2_ 0 14 |_2_ 0 7 |_2_ 1 3 |_2_ 1 1 |_2_ 1 0 quociente = 0 AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES Decimal Binário REGRA: 2) Os “restos” irão formar o número convertido 451 |_2_ 1 225 |_2_ 1 112 |_2_ 0 56 |_2_ 0 28 |_2_ 0 14 |_2_ 0 7 |_2_ 1 3 |_2_ 1 1 |_2_ 1 0 quociente = 0 AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES Decimal Binário REGRA: 2) Os “restos” irão formar o número convertido 451 |_2_ 1 225 |_2_ 1 112 |_2_ 0 56 |_2_ 0 28 |_2_ 0 14 |_2_ 0 7 |_2_ 1 3 |_2_ 1 1 |_2_ 1 0 quociente = 0 Então: 45110 = 1110000112 AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES Decimal Binário REGRA: 2) Os “restos” irão formar o número convertido 451 |_2_ 1 225 |_2_ 1 112 |_2_ 0 56 |_2_ 0 28 |_2_ 0 14 |_2_ 0 7 |_2_ 1 3 |_2_ 1 1 |_2_ 1 0 quociente = 0 Então: 45110 = 1110000112 Provando: 1110000112 = 1*28+1*27+1*26+1*21+1*20= 256+128+64+2+1 = 451 AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES Decimal Hexadecimal REGRA: 1) Realizar divisões sucessivas por 16 enquanto quociente zero 451 |_16_ 3 28 |_16_ 12 1 |_16_ 1 0 quociente = 0 AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES Decimal Hexadecimal REGRA: 2) Os “restos” irão formar o número convertido 451 |_16_ 3 28 |_16_ 12 1 |_16_ 1 0 quociente = 0 Então: 45110 = 1C316 AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES Decimal Hexadecimal REGRA: 2) Os “restos” irão formar o número convertido 451 |_16_ 3 28 |_16_ 12 1 |_16_ 1 0 quociente = 0 Então: 45110 = 1C316 Provando 1C316= 1*16 2+12*161+3*160 = 256+192+3 = 451 AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES Binária Hexadecimal Cada quatro bits formam um algarismo hexadecimal... ... pois 24 = 16 1 1 1 0 0 0 0 1 1 AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES Binária Hexadecimal Cada quatro bits formam um algarismo hexadecimal... ... pois 24 = 16 0 0 0 1 1 1 0 0 0 0 1 1 3 AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES Binária Hexadecimal Cada quatro bits formam um algarismo hexadecimal... ... pois 24 = 16 0 0 0 1 1 1 0 0 0 0 1 1 3 12 = C AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES Binária Hexadecimal Cada quatro bits formam um algarismo hexadecimal... ... pois 24 = 16 0 0 0 1 1 1 0 0 0 0 1 1 3 12 = C 1 AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES Hexadecimal Binário Cada algarismo é representado por 4 bits... ... pois, 24 = 16 1 C 3 AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES Hexadecimal Binário Cada algarismo é representado por 4 bits... ... pois, 24 = 16 1 C 3 0 0 1 1 AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES Hexadecimal Binário Cada algarismo é representado por 4 bits... ... pois, 24 = 16 1 C 3 R: 1 1 1 0 0 0 0 1 1 0 0 1 1 1 1 0 0 AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES Hexadecimal Binário Cada algarismo é representado por 4 bits... ... pois, 24 = 16 1 C 3 R: 1 1 1 0 0 0 0 1 1 0 0 1 1 1 1 0 0 0 0 0 1 AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES E OS NÚMEROS NEGATIVOS? SINAL e MAGNITUDE -10 = 1 1010 sinal magnitude • Um bit reservado para sinal • Duas representações para o ZERO AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES Complemento a 1 -10 = 1 0 1 0 1 • Diferença entre cada algarismo do número e o maior algarismo possível na base • Para a base 2 o maior algarismo é o 1 e, para este caso, equivale a inverter todos os dígitos • Para n bits metade das combinações representa números positivos e a outra metade números negativos • Duas representações para o ZERO 1010 invertido sinal E OS NÚMEROS NEGATIVOS? AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES Complemento a 2 -10 = 1 0 1 1 0 • Obtido a partir do complemento a 1 de um número binário, somando-se 1 • Para n bits metade das combinações representa números positivos e a outra metade números negativos • Uma única representação para o ZERO • Representação mais utilizada sinal 0101 + 1 E OS NÚMEROS NEGATIVOS? AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES Dois números positivos, representados por seis bits (n=6): 10 = (001010)2 e 7 = (000111)2 Soma: 10 + 7 001010 + 000111 010001 17 Subtração: 10 – 7 ? 7 – 10 ? SOMANDO E SUBTRAINDO AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES SM C1 C2 -7 100111 111000 111001 -10 101010 110101 110110 A operação depende da forma de representação do númeronegativo SOMANDO E SUBTRAINDO AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES • Registra o sinal do maior número e subtrai a magnitude 0 01010 (10) 1 00111 (-7) 0 00011 (3) SOMANDO E SUBTRAINDO: SINAL E MAGNITUDE Lembrem-se... Para subtrair 1 de 0 é preciso “pedir emprestado” AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES • Efetua a soma bit a bit (inclusive sinal) • “vai um” para fora do número é somado ao resultado • Se não houver “vai um” para fora do número, o resultado é negativo e deve ser complementado (mantendo o sinal) 1 11 “vai um” 001010 (10) + 111000 (-7) 000010 + 1 000011 (3) SOMANDO E SUBTRAINDO: COMPLEMENTO A 1 AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES • Efetua a soma bit a bit (inclusive sinal) • “vai um” para fora do número é somado ao resultado • Se não houver “vai um” para fora do número, o resultado é negativo e deve ser complementado (mantendo o sinal) 1 11 “vai um” 001010 (10) + 111000 (-7) 000010 + 1 000011 (3) SOMANDO E SUBTRAINDO: COMPLEMENTO A 1 111 “vai um” 110101 (-10) + 000111 (7) 111100 100011 (-3) AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES • Efetua a soma bit a bit (inclusive sinal) • “vai um” para fora do número indica resultado positivo • Se não houver “vai um” para fora do número, o resultado é negativo e deve ser complementado (mantendo o sinal) 1 11 “vai um” 001010 (10) + 111001 (-7) 000011 000011 (3) SOMANDO E SUBTRAINDO: COMPLEMENTO A 2 AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES • Efetua a soma bit a bit (inclusive sinal) • “vai um” para fora do número indica resultado positivo • Se não houver “vai um” para fora do número, o resultado é negativo e deve ser complementado (mantendo o sinal) 1 11 “vai um” 001010 (10) + 111001 (-7) 000011 000011 (3) 11 “vai um” 110110 (-10) + 000111 (7) 111101 100010 + 1 100011 (-3) SOMANDO E SUBTRAINDO: COMPLEMENTO A 2 AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES American Standard Code for Information Interchange (ASCII) LETRAS E SÍMBOLOS AULA 3 – REPRESENTAÇÃO DE DADOS ORGANIZAÇÃO DE COMPUTADORES RESUMINDO •Os números podem ser representados em bases diferentes •Podemos alterar a representação de um número alterando a base • Todos os caracteres possuem uma representação numérica •Você deve praticar!
Compartilhar