This commit is contained in:
krahets 2023-07-29 04:48:28 +08:00
parent a73b3f1714
commit e0d4aed887
18 changed files with 34 additions and 28 deletions

View file

@ -7,7 +7,7 @@ icon: material/help-circle-outline
<div class="center-table" markdown>
![附录](../assets/covers/chapter_appendix.jpg){ width="70%" }
![附录](../assets/covers/chapter_appendix.jpg){ width="600" }
</div>

View file

@ -7,7 +7,7 @@ icon: material/view-list-outline
<div class="center-table" markdown>
![数组与链表](../assets/covers/chapter_array_and_linkedlist.jpg){ width="70%" }
![数组与链表](../assets/covers/chapter_array_and_linkedlist.jpg){ width="600" }
</div>

View file

@ -7,7 +7,7 @@ icon: material/map-marker-path
<div class="center-table" markdown>
![回溯](../assets/covers/chapter_backtracking.jpg){ width="70%" }
![回溯](../assets/covers/chapter_backtracking.jpg){ width="600" }
</div>

View file

@ -7,7 +7,7 @@ icon: material/timer-sand
<div class="center-table" markdown>
![复杂度](../assets/covers/chapter_complexity_analysis.jpg){ width="70%" }
![复杂度](../assets/covers/chapter_complexity_analysis.jpg){ width="600" }
</div>

View file

@ -7,7 +7,7 @@ icon: material/shape-outline
<div class="center-table" markdown>
![数据结构](../assets/covers/chapter_data_structure.jpg){ width="70%" }
![数据结构](../assets/covers/chapter_data_structure.jpg){ width="600" }
</div>

View file

@ -94,25 +94,31 @@ $$
细心的你可能会发现:`int` 和 `float` 长度相同,都是 4 bytes但为什么 `float` 的取值范围远大于 `int` ?这非常反直觉,因为按理说 `float` 需要表示小数,取值范围应该变小才对。
实际上,这是因为浮点数 `float` 采用了不同的表示方式。根据 IEEE 754 标准32-bit 长度的 `float` 由以下部分构成:
- 符号位 $\mathrm{S}$ :占 1 bit 。
- 指数位 $\mathrm{E}$ :占 8 bits 。
- 分数位 $\mathrm{N}$ :占 24 bits ,其中 23 位显式存储。
设 32-bit 二进制数的第 $i$ 位为 $b_i$ ,则 `float` 值的计算方法定义为:
实际上,**这是因为浮点数 `float` 采用了不同的表示方式**。记一个 32-bit 长度的二进制数为:
$$
\text { val } = (-1)^{b_{31}} \times 2^{\left(b_{30} b_{29} \ldots b_{23}\right)_2-127} \times\left(1 . b_{22} b_{21} \ldots b_0\right)_2
b_{31} b_{30} b_{29} \ldots b_2 b_1 b_0
$$
转化到十进制下的计算公式为
根据 IEEE 754 标准32-bit 长度的 `float` 由以下部分构成:
- 符号位 $\mathrm{S}$ :占 1 bit ,对应 $b_{31}$ 。
- 指数位 $\mathrm{E}$ :占 8 bits ,对应 $b_{30} b_{29} \ldots b_{23}$ 。
- 分数位 $\mathrm{N}$ :占 23 bits ,对应 $b_{22} b_{21} \ldots b_0$ 。
二进制数 `float` 对应的值的计算方法:
$$
\text { val }=(-1)^{\mathrm{S}} \times 2^{\mathrm{E} -127} \times (1 + \mathrm{N})
\text {val} = (-1)^{b_{31}} \times 2^{\left(b_{30} b_{29} \ldots b_{23}\right)_2-127} \times\left(1 . b_{22} b_{21} \ldots b_0\right)_2
$$
其中各项的取值范围为
转化到十进制下的计算公式:
$$
\text {val}=(-1)^{\mathrm{S}} \times 2^{\mathrm{E} -127} \times (1 + \mathrm{N})
$$
其中各项的取值范围:
$$
\begin{aligned}

View file

@ -8,7 +8,7 @@ status: new
<div class="center-table" markdown>
![分治](../assets/covers/chapter_divide_and_conquer.jpg){ width="70%" }
![分治](../assets/covers/chapter_divide_and_conquer.jpg){ width="600" }
</div>

View file

@ -8,7 +8,7 @@ status: new
<div class="center-table" markdown>
![动态规划](../assets/covers/chapter_dynamic_programming.jpg){ width="70%" }
![动态规划](../assets/covers/chapter_dynamic_programming.jpg){ width="600" }
</div>

View file

@ -7,7 +7,7 @@ icon: material/graphql
<div class="center-table" markdown>
![](../assets/covers/chapter_graph.jpg){ width="70%" }
![](../assets/covers/chapter_graph.jpg){ width="600" }
</div>

View file

@ -8,7 +8,7 @@ status: new
<div class="center-table" markdown>
![贪心](../assets/covers/chapter_greedy.jpg){ width="70%" }
![贪心](../assets/covers/chapter_greedy.jpg){ width="600" }
</div>

View file

@ -7,7 +7,7 @@ icon: material/table-search
<div class="center-table" markdown>
![散列表](../assets/covers/chapter_hashing.jpg){ width="70%" }
![散列表](../assets/covers/chapter_hashing.jpg){ width="600" }
</div>

View file

@ -7,7 +7,7 @@ icon: material/family-tree
<div class="center-table" markdown>
![](../assets/covers/chapter_heap.jpg){ width="70%" }
![](../assets/covers/chapter_heap.jpg){ width="600" }
</div>

View file

@ -7,7 +7,7 @@ icon: material/calculator-variant-outline
<div class="center-table" markdown>
![初识算法](../assets/covers/chapter_introduction.jpg){ width="70%" }
![初识算法](../assets/covers/chapter_introduction.jpg){ width="600" }
</div>

View file

@ -7,7 +7,7 @@ icon: material/book-open-outline
<div class="center-table" markdown>
![前言](../assets/covers/chapter_preface.jpg){ width="70%" }
![前言](../assets/covers/chapter_preface.jpg){ width="600" }
</div>

View file

@ -7,7 +7,7 @@ icon: material/text-search
<div class="center-table" markdown>
![搜索](../assets/covers/chapter_searching.jpg){ width="70%" }
![搜索](../assets/covers/chapter_searching.jpg){ width="600" }
</div>

View file

@ -7,7 +7,7 @@ icon: material/sort-ascending
<div class="center-table" markdown>
![排序](../assets/covers/chapter_sorting.jpg){ width="70%" }
![排序](../assets/covers/chapter_sorting.jpg){ width="600" }
</div>

View file

@ -7,7 +7,7 @@ icon: material/stack-overflow
<div class="center-table" markdown>
![栈与队列](../assets/covers/chapter_stack_and_queue.jpg){ width="70%" }
![栈与队列](../assets/covers/chapter_stack_and_queue.jpg){ width="600" }
</div>

View file

@ -7,7 +7,7 @@ icon: material/graph-outline
<div class="center-table" markdown>
![](../assets/covers/chapter_tree.jpg){ width="70%" }
![](../assets/covers/chapter_tree.jpg){ width="600" }
</div>