Binary arithmetic · Aritmética binária
| English | Português |
|---|---|
| register/ˈredʒɪstə/ | registrador |
| overflow/ˌəʊvəˈfləʊ/ | overflow |
| two's complement/tuːz ˈkɒmplɪmənt/ | complemento de dois |
| logical shift/ˈlɒdʒɪkl ʃɪft/ | deslocamento lógico |
| most significant bit/məʊst sɪɡˈnɪfɪkənt bɪt/ | bit mais significativo |
Doing maths with 1s and 0s
- Computers add, shift and store negative numbers — all in binary.
- An 8-bit register 寄存器 has limits, so results can overflow 溢出.
- Two's complement 补码 lets us store negatives.
Fazendo matemática com 1s e 0s
- Computadores somam, deslocam e armazenam números negativos — tudo em binário.
- Um registrador de 8 bits 寄存器 tem limites, então resultados podem transbordar 溢出.
- Complemento de dois 补码 permite armazenar negativos.
Binary addition and overflow
- Add column by column from the right, carrying a 1: $1+1 = 10$ (write 0, carry 1).
- Example:
01110110(118) +00110000(48) =10100110(166). - An 8-bit register holds 0–255. A result above 255 needs a 9th bit that won't fit — this is overflow, and the stored answer is wrong.
An 8-bit place-value chart. The 1s sit under the values that add up to 150 (128 + 16 + 4 + 2).
Adição binária e overflow
- Some coluna por coluna da direita, carregando um 1: $1+1 = 10$ (escreva 0, carregue 1).
- Exemplo:
01110110(118) +00110000(48) =10100110(166). - Um registrador de 8 bits armazena 0–255. Um resultado acima de 255 precisa de um 9º bit que não caberá — isso é overflow, e a resposta armazenada estará errada.

Um gráfico de valor posicional de 8 bits. Os 1s ficam abaixo dos valores que somam 150 (128 + 16 + 4 + 2).
Binary arithmetic · Aritmética binária
byte = Σ place values · byte = Σ valores de posição
See how an 8-bit pattern stores a number from 0 to 255. · Veja como um padrão de 8 bits armazena um número de 0 a 255.
Add the binary numbers 0101 + 0011. Give the 4-bit result. · Some os números binários 0101 + 0011. Dê o resultado de 4 bits.
5 + 3 = 8 = 1000.
Overflow in an 8-bit register happens when: · Estouro em um registro de 8 bits acontece quando:
An 8-bit register holds 0–255; a bigger result needs a 9th bit that cannot fit, so it is lost. · Um registro de 8 bits segura 0–255; um resultado maior precisa de um 9º bit que não cabe, então é perdido.
Logical binary shift
- A logical shift 逻辑移位 moves all bits left or right; bits off the end are lost and zeros fill the gap.
- A left shift multiplies by 2 per place; a right shift divides by 2 per place.
- Example:
00110101(53) left-shifted by 2 →11010100(212) = $53 \times 4$.
Each hexadecimal digit becomes its own 4-bit group (nibble): F = 1111, 0 = 0000, 8 = 1000.
Deslocamento lógico binário
- Um deslocamento lógico 逻辑移位 move todos os bits para a esquerda ou direita; bits que saem das extremidades são perdidos e zeros preenchem o espaço.
- Um deslocamento para a esquerda multiplica por 2 por posição; um deslocamento para a direita divide por 2 por posição.
- Exemplo:
00110101(53) deslocado para a esquerda em 2 posições →11010100(212) = $53 \times 4$.

Cada dígito hexadecimal torna-se seu próprio grupo de 4 bits (nibble): F = 1111, 0 = 0000, 8 = 1000.
A logical left shift by 1 multiplies an unsigned number by what? · Um deslocamento lógico à esquerda em 1 multiplica um número sem sinal por quê?
Each left-shift place multiplies by 2 (a right shift divides by 2). · Cada posição de deslocamento à esquerda multiplica por 2 (um deslocamento à direita divide por 2).
00110101 is 53. After a logical left shift of 2 places, what denary value does it hold? · 00110101 é 53. Após um deslocamento lógico à esquerda de 2 posições, qual valor decimal ele segura?
Left shift by 2 = ×4: 53 × 4 = 212 (11010100). · Deslocamento à esquerda em 2 = ×4: 53 × 4 = 212 (11010100).
Two's complement (negatives)
- In two's complement, the most significant bit 最高有效位 has a negative value:
-128 64 32 16 8 4 2 1. - MSB 0 → positive; MSB 1 → negative.
- To make a number negative: write the positive, flip every bit, then add 1. e.g. $+40$ =
00101000→ flip11010111→ +1 →11011000= $-40$. - Range of 8-bit two's complement: −128 to +127.
The most significant bit is worth −128, so 11011000 = −128 + 64 + 16 + 8 = −40
Complemento de dois (negativos)
- Em complemento de dois, o bit mais significativo 最高有效位 tem um valor negativo:
-128 64 32 16 8 4 2 1. - MSB 0 → positivo; MSB 1 → negativo.
- Para tornar um número negativo: escreva o positivo, inverta todos os bits, depois adicione 1. ex. $+40$ =
00101000→ inverta11010111→ +1 →11011000= $-40$. - Intervalo de complemento de dois de 8 bits: -128 a +127.

O bit mais significativo vale −128, então 11011000 = −128 + 64 + 16 + 8 = −40
What is the most negative value an 8-bit two's complement number can store? · Qual é o valor mais negativo que um número de complemento de dois de 8 bits pode armazenar?
The MSB is worth −128, so the range is −128 to +127. · O MSB vale −128, então a faixa é −128 a +127.
You've got it
- add binary with carries; overflow = result needs a 9th bit an 8-bit register can't hold (0–255)
- logical shift: left = ×2, right = ÷2 per place; bits off the end are lost
- two's complement: MSB worth −128; flip bits and add 1 to negate; range −128 to +127
Entendeu?
- adicione binário com carreias; overflow = resultado precisa de um 9º bit que um registrador de 8 bits não pode guardar (0–255)
- deslocamento lógico: esquerda = ×2, direita = ÷2 por posição; bits que saem são perdidos
- complemento de dois: MSB vale −128; inverte bits e adiciona 1 para negar; intervalo -128 a +127