From e0d4aed88712f154e2340d039c10ce4abd05919b Mon Sep 17 00:00:00 2001 From: krahets Date: Sat, 29 Jul 2023 04:48:28 +0800 Subject: [PATCH] build --- chapter_appendix/index.md | 2 +- chapter_array_and_linkedlist/index.md | 2 +- chapter_backtracking/index.md | 2 +- chapter_computational_complexity/index.md | 2 +- chapter_data_structure/index.md | 2 +- chapter_data_structure/number_encoding.md | 28 ++++++++++++++--------- chapter_divide_and_conquer/index.md | 2 +- chapter_dynamic_programming/index.md | 2 +- chapter_graph/index.md | 2 +- chapter_greedy/index.md | 2 +- chapter_hashing/index.md | 2 +- chapter_heap/index.md | 2 +- chapter_introduction/index.md | 2 +- chapter_preface/index.md | 2 +- chapter_searching/index.md | 2 +- chapter_sorting/index.md | 2 +- chapter_stack_and_queue/index.md | 2 +- chapter_tree/index.md | 2 +- 18 files changed, 34 insertions(+), 28 deletions(-) diff --git a/chapter_appendix/index.md b/chapter_appendix/index.md index 32a30e4ca..f1a482893 100644 --- a/chapter_appendix/index.md +++ b/chapter_appendix/index.md @@ -7,7 +7,7 @@ icon: material/help-circle-outline
-![附录](../assets/covers/chapter_appendix.jpg){ width="70%" } +![附录](../assets/covers/chapter_appendix.jpg){ width="600" }
diff --git a/chapter_array_and_linkedlist/index.md b/chapter_array_and_linkedlist/index.md index d9d71aa7a..09edf5c98 100644 --- a/chapter_array_and_linkedlist/index.md +++ b/chapter_array_and_linkedlist/index.md @@ -7,7 +7,7 @@ icon: material/view-list-outline
-![数组与链表](../assets/covers/chapter_array_and_linkedlist.jpg){ width="70%" } +![数组与链表](../assets/covers/chapter_array_and_linkedlist.jpg){ width="600" }
diff --git a/chapter_backtracking/index.md b/chapter_backtracking/index.md index adfd2b7bb..ab909f632 100644 --- a/chapter_backtracking/index.md +++ b/chapter_backtracking/index.md @@ -7,7 +7,7 @@ icon: material/map-marker-path
-![回溯](../assets/covers/chapter_backtracking.jpg){ width="70%" } +![回溯](../assets/covers/chapter_backtracking.jpg){ width="600" }
diff --git a/chapter_computational_complexity/index.md b/chapter_computational_complexity/index.md index dfbd787f5..958e013ea 100644 --- a/chapter_computational_complexity/index.md +++ b/chapter_computational_complexity/index.md @@ -7,7 +7,7 @@ icon: material/timer-sand
-![复杂度](../assets/covers/chapter_complexity_analysis.jpg){ width="70%" } +![复杂度](../assets/covers/chapter_complexity_analysis.jpg){ width="600" }
diff --git a/chapter_data_structure/index.md b/chapter_data_structure/index.md index a1b9997ae..9d829c9ee 100644 --- a/chapter_data_structure/index.md +++ b/chapter_data_structure/index.md @@ -7,7 +7,7 @@ icon: material/shape-outline
-![数据结构](../assets/covers/chapter_data_structure.jpg){ width="70%" } +![数据结构](../assets/covers/chapter_data_structure.jpg){ width="600" }
diff --git a/chapter_data_structure/number_encoding.md b/chapter_data_structure/number_encoding.md index e61c78acd..20f276196 100644 --- a/chapter_data_structure/number_encoding.md +++ b/chapter_data_structure/number_encoding.md @@ -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} diff --git a/chapter_divide_and_conquer/index.md b/chapter_divide_and_conquer/index.md index d018d17ca..8a6687739 100644 --- a/chapter_divide_and_conquer/index.md +++ b/chapter_divide_and_conquer/index.md @@ -8,7 +8,7 @@ status: new
-![分治](../assets/covers/chapter_divide_and_conquer.jpg){ width="70%" } +![分治](../assets/covers/chapter_divide_and_conquer.jpg){ width="600" }
diff --git a/chapter_dynamic_programming/index.md b/chapter_dynamic_programming/index.md index 8ad44fd23..2dc2c6abb 100644 --- a/chapter_dynamic_programming/index.md +++ b/chapter_dynamic_programming/index.md @@ -8,7 +8,7 @@ status: new
-![动态规划](../assets/covers/chapter_dynamic_programming.jpg){ width="70%" } +![动态规划](../assets/covers/chapter_dynamic_programming.jpg){ width="600" }
diff --git a/chapter_graph/index.md b/chapter_graph/index.md index 22b487eee..27c50834f 100644 --- a/chapter_graph/index.md +++ b/chapter_graph/index.md @@ -7,7 +7,7 @@ icon: material/graphql
-![图](../assets/covers/chapter_graph.jpg){ width="70%" } +![图](../assets/covers/chapter_graph.jpg){ width="600" }
diff --git a/chapter_greedy/index.md b/chapter_greedy/index.md index d226852b6..af6553a5a 100644 --- a/chapter_greedy/index.md +++ b/chapter_greedy/index.md @@ -8,7 +8,7 @@ status: new
-![贪心](../assets/covers/chapter_greedy.jpg){ width="70%" } +![贪心](../assets/covers/chapter_greedy.jpg){ width="600" }
diff --git a/chapter_hashing/index.md b/chapter_hashing/index.md index 163cdf322..46163cb77 100644 --- a/chapter_hashing/index.md +++ b/chapter_hashing/index.md @@ -7,7 +7,7 @@ icon: material/table-search
-![散列表](../assets/covers/chapter_hashing.jpg){ width="70%" } +![散列表](../assets/covers/chapter_hashing.jpg){ width="600" }
diff --git a/chapter_heap/index.md b/chapter_heap/index.md index 1d9a2fc21..cba2ef77e 100644 --- a/chapter_heap/index.md +++ b/chapter_heap/index.md @@ -7,7 +7,7 @@ icon: material/family-tree
-![堆](../assets/covers/chapter_heap.jpg){ width="70%" } +![堆](../assets/covers/chapter_heap.jpg){ width="600" }
diff --git a/chapter_introduction/index.md b/chapter_introduction/index.md index 6f321a25f..ea6636773 100644 --- a/chapter_introduction/index.md +++ b/chapter_introduction/index.md @@ -7,7 +7,7 @@ icon: material/calculator-variant-outline
-![初识算法](../assets/covers/chapter_introduction.jpg){ width="70%" } +![初识算法](../assets/covers/chapter_introduction.jpg){ width="600" }
diff --git a/chapter_preface/index.md b/chapter_preface/index.md index 6ea4d5362..13ebb3a06 100644 --- a/chapter_preface/index.md +++ b/chapter_preface/index.md @@ -7,7 +7,7 @@ icon: material/book-open-outline
-![前言](../assets/covers/chapter_preface.jpg){ width="70%" } +![前言](../assets/covers/chapter_preface.jpg){ width="600" }
diff --git a/chapter_searching/index.md b/chapter_searching/index.md index 656945ffd..e15de9bf6 100644 --- a/chapter_searching/index.md +++ b/chapter_searching/index.md @@ -7,7 +7,7 @@ icon: material/text-search
-![搜索](../assets/covers/chapter_searching.jpg){ width="70%" } +![搜索](../assets/covers/chapter_searching.jpg){ width="600" }
diff --git a/chapter_sorting/index.md b/chapter_sorting/index.md index 63faa100a..896b29d96 100644 --- a/chapter_sorting/index.md +++ b/chapter_sorting/index.md @@ -7,7 +7,7 @@ icon: material/sort-ascending
-![排序](../assets/covers/chapter_sorting.jpg){ width="70%" } +![排序](../assets/covers/chapter_sorting.jpg){ width="600" }
diff --git a/chapter_stack_and_queue/index.md b/chapter_stack_and_queue/index.md index 0597b76e4..0f970df58 100644 --- a/chapter_stack_and_queue/index.md +++ b/chapter_stack_and_queue/index.md @@ -7,7 +7,7 @@ icon: material/stack-overflow
-![栈与队列](../assets/covers/chapter_stack_and_queue.jpg){ width="70%" } +![栈与队列](../assets/covers/chapter_stack_and_queue.jpg){ width="600" }
diff --git a/chapter_tree/index.md b/chapter_tree/index.md index df8bef61b..6899e9815 100644 --- a/chapter_tree/index.md +++ b/chapter_tree/index.md @@ -7,7 +7,7 @@ icon: material/graph-outline
-![树](../assets/covers/chapter_tree.jpg){ width="70%" } +![树](../assets/covers/chapter_tree.jpg){ width="600" }