This commit is contained in:
许大仙 2024-08-19 15:40:31 +08:00
parent 45fec76a11
commit 53ce49fc47
27 changed files with 93 additions and 37 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 410 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 483 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 426 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 495 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 161 KiB

After

Width:  |  Height:  |  Size: 451 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 522 KiB

View File

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 172 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 156 KiB

After

Width:  |  Height:  |  Size: 74 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 188 KiB

After

Width:  |  Height:  |  Size: 75 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 211 KiB

After

Width:  |  Height:  |  Size: 88 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 253 KiB

After

Width:  |  Height:  |  Size: 161 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 317 KiB

After

Width:  |  Height:  |  Size: 118 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 253 KiB

After

Width:  |  Height:  |  Size: 172 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 380 KiB

After

Width:  |  Height:  |  Size: 156 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 398 KiB

After

Width:  |  Height:  |  Size: 188 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 507 KiB

After

Width:  |  Height:  |  Size: 211 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 534 KiB

After

Width:  |  Height:  |  Size: 253 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 317 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 253 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 380 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 398 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 507 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 534 KiB

View File

@ -815,7 +815,7 @@ int main() {
> [!NOTE]
>
> 在十六进制中,除了 0 到 9 这十个数字之外,还引入了字母,以便表示超过 9 的值。字母 A 对应十进制的 10 ,字母 B 对应十进制的 11 ,以此类推,字母 F 对应十进制的 15
> 在十六进制中,除了 `0``9` 这十个数字之外,还引入了字母,以便表示超过 `9` 的值。其中,字母 `A` 对应十进制的 `10` ,字母 `B` 对应十进制的 `11` ,字母 `C` 对应十进制的 `12`,字母 `D` 对应十进制的 `13`,字母 `E` 对应十进制的 `14`,字母 `F` 对应十进制的 `15`
* 进制的换算举例,如下所示:
@ -963,6 +963,8 @@ int main() {
## 3.3 进制的运算规则
### 3.3.1 概述
* `十进制`的运算规则,如下所示:
* 逢`十`进`一`(针对加法而言)。
* 借`一`当`十`(针对减法而言)。
@ -976,17 +978,47 @@ int main() {
* 逢`十六`进`一`(针对加法而言)。
* 借`一`当`十六`(针对减法而言)。
### 3.3.2 二进制的运算
* 二进制的加法:`1 + 0 = 1` 、`1 + 1 = 10`、`11 + 10 = 101`、`111 + 111 = 1110`。
![](./assets/19.svg)
* 二进制的减法:`1 - 0 = 1` 、`10 - 1 = 1`、`101 - 11 = 10`、`1100 - 111 = 101` 。
![](./assets/20.svg)
### 3.3.3 八进制的运算
* 八进制的加法:`3 + 4 = 7` 、`5 + 6 = 13`、`75 + 42 = 137`、`2427 + 567 = 3216`。
![](./assets/21.svg)
* 八进制的减法:`6 - 4 = 2` 、`52 - 27 = 33`、`307 - 141 = 146`、`7430 - 1451 = 5757` 。
![](./assets/22.svg)
### 3.3.4 十六进制的运算
* 十六进制的加法:`6 + 7 = D` 、`18 + BA = D2`、`595 + 792 = D27`、`2F87 + F8A = 3F11`。
![](./assets/23.svg)
* 十六进制的减法:`D - 3 = A` 、`52 - 2F = 23`、`E07 - 141 = CC6`、`7CA0 - 1CB1 = 5FEF` 。
![](./assets/24.svg)
## 3.4 进制的转换
### 3.4.1 概述
* 不同进制的转换,如下所示:
![](./assets/19.png)
![](./assets/25.png)
* 在计算机中,数据是从右往左的方式排列的;其中,最右边的是低位,最左边的是高位,即:
![](./assets/20.svg)
![](./assets/26.svg)
### 3.4.2 二进制和十进制的转换
@ -1003,13 +1035,13 @@ int main() {
* 示例:十进制转十进制
![](./assets/21.svg)
![](./assets/27.svg)
* 示例:二进制转十进制
![](./assets/22.svg)
![](./assets/28.svg)
#### 3.4.2.2 十进制转换二进制
@ -1025,13 +1057,13 @@ int main() {
* 示例:十进制转十进制
![](./assets/23.svg)
![](./assets/29.svg)
* 示例:十进制转二进制
![](./assets/24.svg)
![](./assets/30.svg)
### 3.4.3 二进制转八进制
@ -1041,7 +1073,7 @@ int main() {
* 示例011 101 001 -> 351
![](./assets/25.svg)
![](./assets/31.svg)
@ -1053,7 +1085,7 @@ int main() {
* 示例1110 1001 -> 0xE9
![](./assets/26.svg)
![](./assets/32.svg)
## 3.5 原码、反码和补码
@ -1065,7 +1097,7 @@ int main() {
>
> 这里讨论的适用于`符号位`的整数int 等;而不适用于`无符号位`的整数unsinged int 等。
![](./assets/27.svg)
![](./assets/33.svg)
* 真值(数据位):因为机器数带有符号位,所以机器数的形式值不等于其真实表示的值(真值),以机器数 1000 0001 为例,其真正表示的值(首位是符号位)为 -1而形式值却是 129 ,因此将带有符号位的机器数的真正表示的值称为机器数的真值。
@ -1073,7 +1105,7 @@ int main() {
>
> 这里讨论的适用于`符号位`的整数int 等;而不适用于`无符号位`的整数unsinged int 等。
![](./assets/28.svg)
![](./assets/34.svg)
### 3.5.2 原码
@ -1146,11 +1178,11 @@ int main() {
* 如果 `0` ,按照 `+0` 的情况进行处理,如下所示:
![](./assets/29.svg)
![](./assets/35.svg)
* 如果 `0` ,按照 `-0` 的情况进行处理,如下所示:
![](./assets/30.svg)
![](./assets/36.svg)
> [!IMPORTANT]
>
@ -1183,7 +1215,7 @@ int main() {
>
> 直接使用原码表示整数,让符号位也参与运算,那么对于减法来说,结果显然是不正确的。
![](./assets/31.svg)
![](./assets/37.svg)
* 于是,人们开始继续探索,不断试错,终于设计出了`反码`,如下所示:
@ -1191,7 +1223,7 @@ int main() {
>
> 直接使用反码表示整数,让符号位也参与运算,对于 6 +-18来说结果貌似正确。
![](./assets/32.svg)
![](./assets/38.svg)
* 如果我们将`被减数`和`减数`对调一下,即:计算 `18 - 6` 的结果,也就是 `18 +-6`的结果,继续采用`反码`来进行运算,如下所示:
@ -1200,15 +1232,15 @@ int main() {
> * ① 6 - 186+-18如果采用`反码`计算结果是正确的但是18 - 618 +-6如果采用`反码`计算,结果相差 1 。
> * ② 可以推断:如果按照`反码`来计算,小数 - 大数,结果正确;而大数 - 小数,结果相差 1 。
![](./assets/33.svg)
![](./assets/39.svg)
* 对于这个相差的 `1` 必须进行纠正,但是又不能影响`小数-大数`的结果。于是,人们又绞尽脑汁设计出了`补码`,给`反码`打了一个`“补丁”`,终于把相差的 `1` 给纠正过来了。那么,`6 - 18` 按照`补码`的运算过程,如下所示:
![](./assets/34.svg)
![](./assets/40.svg)
* 那么,`18 - 6` 按照`补码`的运算过程,如下所示:
![](./assets/35.svg)
![](./assets/41.svg)
> [!IMPORTANT]
>