Binary arithmetic · 二进制算术
| English | 中文 | Pinyin · 拼音 |
|---|---|---|
| register/ˈredʒɪstə/ | 寄存器 | jì cún qì |
| overflow/ˌəʊvəˈfləʊ/ | 溢出 | yì chū |
| two's complement/tuːz ˈkɒmplɪmənt/ | 补码 | bǔ mǎ |
| logical shift/ˈlɒdʒɪkl ʃɪft/ | 逻辑移位 | luó jí yí wèi |
| most significant bit/məʊst sɪɡˈnɪfɪkənt bɪt/ | 最高有效位 | zuì gāo yǒu xiào wèi |
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.
用 1 和 0 做数学
- 计算机做加法、移位并存储负数——全都用二进制。
- 一个 8 位寄存器有限制,所以结果能溢出(overflow)。
- 二进制补码(two's complement)让我们存储负数。
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).
二进制加法与溢出
- 从右边逐列相加,进位一个 1:$1+1 = 10$(写 0,进位 1)。
- 例子:
01110110(118)+00110000(48)=10100110(166)。 - 一个 8 位寄存器容纳 0–255。一个超过 255 的结果需要一个放不下的第 9 位——这是溢出,而存储的答案是错的。

一个 8 位位值图。1 位于相加得到 150 的那些值下方(128 + 16 + 4 + 2)。
Binary arithmetic · 二进制算术
byte = Σ place values · 字节 = Σ 位值
See how an 8-bit pattern stores a number from 0 to 255. · 看一个 8 位模式如何存储一个 0 到 255 的数。
Add the binary numbers 0101 + 0011. Give the 4-bit result. · 把二进制数 0101 + 0011 相加。给出 4 位结果。
5 + 3 = 8 = 1000. · 5 + 3 = 8 = 1000。
Overflow in an 8-bit register happens when: · 一个 8 位寄存器中的溢出发生在:
An 8-bit register holds 0–255; a bigger result needs a 9th bit that cannot fit, so it is lost. · 一个 8 位寄存器容纳 0–255;一个更大的结果需要一个放不下的第 9 位,所以它丢失。
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.
逻辑二进制移位
- 一个逻辑移位(logical shift)把所有位向左或向右移动;移出末端的位丢失,而零填充空隙。
- 一个左移每个位置乘以 2;一个右移每个位置除以 2。
- 例子:
00110101(53)左移 2 位 →11010100(212)= $53 \times 4$。

每个十六进制数字变成它自己的 4 位组(半字节):F = 1111,0 = 0000,8 = 1000。
A logical left shift by 1 multiplies an unsigned number by what? · 一个左移 1 位把一个无符号数乘以多少?
Each left-shift place multiplies by 2 (a right shift divides by 2). · 每个左移位置乘以 2(一个右移除以 2)。
00110101 is 53. After a logical left shift of 2 places, what denary value does it hold? · 00110101 是 53。在左移 2 位之后,它持有什么十进制值?
Left shift by 2 = ×4: 53 × 4 = 212 (11010100). · 左移 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
二进制补码(负数)
- 在二进制补码中,最高有效位有一个负值:
-128 64 32 16 8 4 2 1。 - MSB 0 → 正;MSB 1 → 负。
- 要使一个数为负:写出正数,翻转每一位,然后加 1。例如 $+40$ =
00101000→ 翻转11010111→ +1 →11011000= $-40$。 - 8 位二进制补码的范围:−128 到 +127。

最高有效位的值为 −128,所以 11011000 = −128 + 64 + 16 + 8 = −40
What is the most negative value an 8-bit two's complement number can store? · 一个 8 位二进制补码数能存储的最负的值是多少?
The MSB is worth −128, so the range is −128 to +127. · MSB 值为 −128,所以范围是 −128 到 +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
你掌握了
- 带进位地做二进制加法;溢出 = 结果需要一个 8 位寄存器放不下的第 9 位(0–255)
- 逻辑移位:左 = ×2,右 = ÷2 每个位置;移出末端的位丢失
- 二进制补码:MSB 值为 −128;翻转位并加 1 来取负;范围 −128 到 +127