Number systems and conversions · Sistemas numéricos e conversões
| English | Português |
|---|---|
| byte/baɪt/ | byte |
| denary/ˈdiːnəri/ | decimal |
| binary/ˈbaɪnəri/ | binária |
| bit/bɪt/ | bit |
| nibble/ˈnɪbl/ | nibble |
| hexadecimal/ˌheksəˈdesɪml/ | hexadecimal |
| register width/ˈredʒɪstə wɪtθ/ | largura do registrador |
| kibi/ˈkɪbi/ | kibi |
The terabyte that was not a terabyte
- In 2005 a Californian bought a hard drive labelled 80 GB. His computer reported 74.5 GB. He sued, and the manufacturers eventually paid out: they had counted a gigabyte as a thousand million bytes, and the operating system had counted it as $2^{30}$.
- Neither was lying. There are two families of prefix, one built on powers of ten and one on powers of two, and they drift further apart the bigger the number gets.
- The whole of data representation rests on that idea: a computer stores nothing but 0s and 1s, and everything else is an agreement about how to read them.
- This lesson is the three number systems, the conversions between them, and the two prefix families.
O terabyte que não era um terabyte
- Em 2005, um californiano comprou um disco rígido rotulado como 80 GB. Seu computador indicou 74.5 GB. Ele processou a empresa e os fabricantes acabaram pagando: eles haviam contado um gigabyte como mil milhões de bytes, enquanto o sistema operativo o contava como $2^{30}$.
- Nenhum deles estava mentindo. Existem duas famílias de prefixos, uma baseada em potências de dez e outra em potências de dois, e elas se afastam cada vez mais conforme o número aumenta.
- Toda a representação de dados baseia-se nessa ideia: um computador armazena apenas 0s e 1s, e tudo o mais é um acordo sobre como interpretá-los.
- Esta lição trata dos três sistemas numéricos, das conversões entre eles e das duas famílias de prefixos.
The three number systems
- Denary 十进制 (base 10) uses digits 0 to 9, with place values that are powers of ten. It is the everyday system.
- Binary 二进制 (base 2) uses 0 and 1, with place values that are powers of two. One digit is a bit 位; 4 bits are a nibble 半字节; 8 bits are a byte 字节.
- Hexadecimal 十六进制 (base 16) uses 0 to 9 then A to F for 10 to 15. One hex digit stands for exactly 4 bits, which is why it is the shorthand programmers use for binary.
| Denary | Binary | Hex |
|---|---|---|
| 10 | 1010 |
A |
| 15 | 1111 |
F |
| 16 | 0001 0000 |
10 |
| 255 | 1111 1111 |
FF |
Every system is place value; only the base changes
Os três sistemas numéricos
- Decimal 十进制 (base 10) usa dígitos de 0 a 9, com valores posicionais que são potências de dez. É o sistema cotidiano.
- Binário 二进制 (base 2) usa 0 e 1, com valores posicionais que são potências de dois. Um dígito é um bit 位; 4 bits formam um nibble 半字节; 8 bits formam um byte 字节.
- Hexadecimal 十六进制 (base 16) usa 0 a 9 seguidos de A a F para 10 a 15. Um dígito hexadecimal equivale exatamente a 4 bits, sendo por isso a forma abreviada usada por programadores para representar binários.
| Decimal | Binário | Hex |
|---|---|---|
| 10 | 1010 |
A |
| 15 | 1111 |
F |
| 16 | 0001 0000 |
10 |
| 255 | 1111 1111 |
FF |

Todos os sistemas usam valor posicional; apenas a base muda
Number systems · Sistemas numéricos
byte = Σ place values · byte = Σ valores de posição
Each bit is worth a power of two — flip the bits and watch the decimal and hex update. · Cada bit vale uma potência de dois — alterne os bits e veja o decimal e hex atualizarem.
How many bits does one hexadecimal digit represent? · Quantos bits um dígito hexadecimal representa?
One hex digit (0–F) covers 16 values = $2^4$, so it maps to exactly 4 bits (a nibble). · Um dígito hex (0–F) cobre 16 valores = $2^4$, então mapeia exatamente 4 bits (um nibble).
How many bits are in one byte? · Quantos bits há em um byte?
A byte is 8 bits (and a nibble is 4 bits). · Um byte tem 8 bits (e um nibble tem 4 bits).
Denary to binary
- Method 1, place values: write the powers of two, $128, 64, 32, 16, 8, 4, 2, 1$, and subtract the largest that fits, repeating with what is left. Put a 1 under each one you used.
- Method 2, repeated division: divide by 2 over and over, writing down each remainder, then read the remainders bottom-up.
- $42 = 32 + 8 + 2$, so the bits under 32, 8 and 2 are 1 and the rest are 0:
0010 1010.
Subtract the biggest power of two that fits, and repeat
Decimal para binário
- Método 1, valores posicionais: escreva as potências de dois, $128, 64, 32, 16, 8, 4, 2, 1$, e subtraia a maior que couber, repetindo com o resto. Coloque 1 embaixo de cada uma que usou.
- Método 2, divisão repetida: divida por 2 repetidamente, anotando cada resto, depois leia os restos de baixo para cima.
- $42 = 32 + 8 + 2$, então os bits embaixo de 32, 8 e 2 são 1 e os demais são 0:
0010 1010.

Subtraia a maior potência de dois que couber, e repita
Convert denary $13$ to binary (8-bit not required — just the significant bits). · Converter denário $13$ para binário (8-bit não é necessário — apenas os bits significativos).
$13 = 8 + 4 + 1$, so the columns 8, 4, 1 are set: 1101. · $13 = 8 + 4 + 1$, então as colunas 8, 4, 1 estão ativadas: 1101.
Convert binary 00101010 to denary. · Converter binário 00101010 para denário.
$32 + 8 + 2 = 42$ (the 32, 8 and 2 columns are set). · $32 + 8 + 2 = 42$ (as colunas 32, 8 e 2 estão ativadas).
Worked example: denary 200 to binary and hex
- $200 = 128 + 64 + 8$, so the 8-bit binary is
1100 1000. - Split into nibbles from the right:
1100is 12, which is C;1000is 8. So the hexadecimal isC8. - Check by place value the other way:
C8$= 12 \times 16 + 8 = 200$. ✓ Always show the working; the conversion itself carries the marks.
Exemplo resolvido: decimal 200 para binário e hex
- $200 = 128 + 64 + 8$, então o binário de 8 bits é
1100 1000. - Divida em nibbles da direita para esquerda:
1100é 12, que é C;1000é 8. Então o hexadecimal éC8. - Verifique pelo valor posicional do outro lado:
C8$= 12 \times 16 + 8 = 200$. ✓ Sempre mostre o trabalho; a conversão em si carrega as marcas.
Binary and hex, both directions
- Binary to hex: group the bits into nibbles from the right, padding the leftmost group with zeros, and convert each nibble.
0010 0010 1110becomes2 2 E, so22E. - Hex to binary: replace each hex digit with its own 4-bit pattern. No arithmetic needed.
- Hex to denary: multiply each digit by its place value, $16^2 = 256$, $16^1 = 16$, $16^0 = 1$.
22E$= 2 \times 256 + 2 \times 16 + 14 = 558$.
Binário e hex, ambos os sentidos
- Binário para hex: agrupe os bits em nibbles da direita para a esquerda, preenchendo o grupo mais à esquerda com zeros, e converta cada nibble.
0010 0010 1110vira2 2 E, logo22E. - Hex para binário: substitua cada dígito hex pelo seu padrão de 4 bits correspondente. Nenhuma aritmética necessária.
- Hex para decimal: multiplique cada dígito por seu valor posicional, $16^2 = 256$, $16^1 = 16$, $16^0 = 1$.
22E$= 2 \times 256 + 2 \times 16 + 14 = 558$.
Convert hexadecimal 2E to denary. · Converter hexadecimal 2E para denário.
$2 \times 16 + 14 = 32 + 14 = 46$ (E is 14). · $2 \times 16 + 14 = 32 + 14 = 46$ (E é 14).
Convert the binary number 0010 0010 1110 to hexadecimal. · Converter o número binário 0010 0010 1110 para hexadecimal.
Each nibble converts on its own, from the right: 0010 = 2, 0010 = 2, 1110 = 14 = E. · Cada nibble converte-se individualmente, da direita: 0010 = 2, 0010 = 2, 1110 = 14 = E.
How many bits does a value need?
- Exam questions fix the register width 寄存器宽度 (8, 12 or 16 bits), and you must pad with leading zeros to that width. $558$ in 12 bits is
0010 0010 1110, never10 0010 1110. - An unsigned integer from 0 to $2^n - 1$ needs $n$ bits: 200 needs 8 bits (8 bits reach 255), 1000 needs 10 bits (10 bits reach 1023), 16 needs 5 bits (4 bits stop at 15).
- One hexadecimal digit needs 4 bits, one BCD digit needs 4 bits, and one ASCII character needs 7 bits, or 8 for extended ASCII.
Quantos bits um valor precisa?
- Questões de exame fixam a largura do registro 寄存器宽度 (8, 12 ou 16 bits), e você deve preencher com zeros à esquerda até essa largura. $558$ em 12 bits é
0010 0010 1110, nunca10 0010 1110. - Um inteiro não assinado de 0 a $2^n - 1$ precisa de $n$ bits: 200 precisa de 8 bits (8 bits chegam a 255), 1000 precisa de 10 bits (10 bits chegam a 1023), 16 precisa de 5 bits (4 bits param em 15).
- Um dígito hexadecimal precisa de 4 bits, um dígito BCD precisa de 4 bits, e um caractere ASCII precisa de 7 bits, ou 8 para ASCII expandido.
Write denary 558 as a 12-bit binary number (four bits per group, spaces allowed). · Escreva 558 denário como número binário de 12 bits (quatro bits por grupo, espaços permitidos).
558 = 512 + 32 + 8 + 4 + 2. Pad with leading zeros to the 12 bits the question asks for; an unpadded answer loses the mark. · 558 = 512 + 32 + 8 + 4 + 2. Preencha com zeros à esquerda para os 12 bits que a questão pede; uma resposta sem preenchimento perde pontos.
Worked example: the minimum number of bits
- A system must store values from 0 to 1000. What is the smallest number of bits?
- Ask which power of two first exceeds 1000. $2^9 = 512$, too small; $2^{10} = 1024$, so ten bits hold 0 to 1023 and 1000 fits.
- The answer is 10 bits, and the reason is the range, not the digit count. A common trap: 16 needs five bits, because four bits stop at 15.
Exemplo resolvido: o número mínimo de bits
- Um sistema deve armazenar valores de 0 a 1000. Qual é o menor número de bits?
- Pergunte qual a potência de dois que primeiramente excede 1000. $2^9 = 512$, muito pequeno; $2^{10} = 1024$, então dez bits armazenam de 0 a 1023 e 1000 cabe.
- A resposta é 10 bits, e a razão é o intervalo, não a contagem de dígitos. Uma armadilha comum: 16 precisa de cinco bits, porque quatro bits param em 15.
What is the smallest number of bits that can store any unsigned value from 0 to 1000? · Qual é o menor número de bits que pode armazenar qualquer valor sem sinal de 0 a 1000?
Nine bits reach 511, ten bits reach 1023. The question is about the range the bits cover, not the number of digits. · Nove bits atingem 511, dez bits atingem 1023. A questão trata do intervalo coberto pelos bits, não do número de dígitos.
Binary prefixes and decimal prefixes
- Decimal prefixes are powers of ten and are used for drive capacities and network speeds: kilo $= 10^3$, mega $= 10^6$, giga $= 10^9$, tera $= 10^{12}$.
- Binary prefixes are powers of two and are used for memory sizes: kibi 二进制千 (Ki) $= 2^{10} = 1024$, mebi (Mi) $= 2^{20}$, gibi (Gi) $= 2^{30}$, tebi (Ti) $= 2^{40}$.
- So a "1 TB" drive holds $10^{12}$ bytes, but an operating system reporting in TiB divides by $2^{40}$ and shows about 0.91. Nothing has been lost; two different units were used.
Prefixos binários e prefixos decimais
- Prefixos decimais são potências de dez e são usados para capacidades de drive e velocidades de rede: kilo $= 10^3$, mega $= 10^6$, giga $= 10^9$, tera $= 10^{12}$.
- Prefixos binários são potências de dois e são usados para tamanhos de memória: kibi kibi (Ki) $= 2^{10} = 1024$, mebi (Mi) $= 2^{20}$, gibi (Gi) $= 2^{30}$, tebi (Ti) $= 2^{40}$.
- Então um drive "1 TB" contém $10^{12}$ bytes, mas um sistema operacional reportando em TiB divide por $2^{40}$ e mostra cerca de 0.91. Nada foi perdido; duas unidades diferentes foram usadas.
How many bytes are in 1 kibibyte (KiB)? · Quantos bytes há em 1 kibibyte (KiB)?
A kibibyte is $2^{10} = 1024$ bytes (a binary prefix, used for memory). · Um kibibyte é $2^{10} = 1024$ bytes (um prefixo binário, usado para memória).
A drive sold as 1 TB holds fewer bytes than 1 TiB of memory. · Um drive vendido como 1 TB possui menos bytes que 1 TiB de memória.
1 TB is 10^12 bytes; 1 TiB is 2^40, about 1.1 x 10^12. Decimal prefixes for drives, binary prefixes for memory. · 1 TB é 10^12 bytes; 1 TiB é 2^40, cerca de 1.1 x 10^12. Prefixos decimais para drives, prefixos binários para memória.
Where hexadecimal is actually used
- Memory addresses and machine code, because one hex digit is exactly one nibble and a byte is exactly two hex digits, so a dump is readable at a glance.
- Colour codes in web pages:
#FF8800is one byte each of red, green and blue. MAC addresses and error codes likewise. - The reason is always the same: hex is a shorthand for binary that a person can read and write without mistakes, not a system the computer itself uses.
Onde hexadecimal é realmente usado
- Endereços de memória e código de máquina, porque um dígito hex é exatamente um nibble e um byte é exatamente dois dígitos hex, então um dump é legível à primeira vista.
- Códigos de cor em páginas web:
#FF8800é um byte cada de vermelho, verde e azul. Endereços MAC e códigos de erro também. - A razão é sempre a mesma: hex é um abreviatura para binário que uma pessoa pode ler e escrever sem erros, não um sistema que o próprio computador usa.
Where is hexadecimal used in practice? Select all · todos that apply. · Onde o hexadecimal é usado na prática? Selecione todos que se aplicam.
Hex is a human-readable shorthand for binary: one digit per nibble, two per byte. The processor itself works in binary. · Hex é um atalho legível para humanos do binário: um dígito por nibble, dois por byte. O próprio processador opera em binário.
Marks that slip away
- Pad to the width the question gives. An unpadded answer loses the mark even when the bits are right.
- Group nibbles from the right, not the left, or every hex digit shifts.
- 4 bits reach 15, 8 bits reach 255, 10 bits reach 1023. "How many bits" is a question about the range.
- A kibibyte is 1024 bytes and a kilobyte is 1000. Say which you used in any size calculation.
Marcas que escapam
- Preencha até a largura que a questão dá. Uma resposta sem preenchimento perde a marca mesmo quando os bits estão certos.
- Agrupe nibbles da direita para a esquerda, não da esquerda para a direita, ou cada dígito hex muda de posição.
- 4 bits alcançam 15, 8 bits alcançam 255, 10 bits alcançam 1023. "Quantos bits" é uma pergunta sobre o intervalo.
- Um kibibyte é 1024 bytes e um kilobyte é 1000. Diga qual você usou em qualquer cálculo de tamanho.
You've got it
- denary base 10, binary base 2 (bit, nibble = 4 bits, byte = 8 bits), hexadecimal base 16 where one digit is exactly one nibble
- denary to binary by subtracting powers of two or by repeated division reading remainders bottom-up; binary to hex by grouping nibbles from the right; hex to denary by place value
- pad to the register width; an unsigned value needs $n$ bits where $2^n$ first exceeds it
- decimal prefixes are powers of ten (drives, networks), binary prefixes powers of two (memory): kibi $= 1024$
Entendeu?
- denary base 10, binary base 2 (bit, nibble = 4 bits, byte = 8 bits), hexadecimal base 16 onde um dígito é exatamente um nibble
- denary para binary subtraindo potências de dois ou por divisão repetida lendo resto de baixo para cima; binary para hex agrupando nibbles da direita; hex para denary por valor posicional
- preencher até a largura do registro; um valor sem sinal precisa de $n$ bits onde $2^n$ primeiramente o excede
- prefixos decimais são potências de dez (drives, redes), prefixos binários potências de dois (memória): kibi $= 1024$