diff --git a/docs/chapter_appendix/index.md b/docs/chapter_appendix/index.md index b54afbc5..8f71d750 100644 --- a/docs/chapter_appendix/index.md +++ b/docs/chapter_appendix/index.md @@ -2,6 +2,6 @@
-![附录](../assets/covers/chapter_appendix.jpg){ width="70%" } +![附录](../assets/covers/chapter_appendix.jpg){ width="600" }
diff --git a/docs/chapter_array_and_linkedlist/index.md b/docs/chapter_array_and_linkedlist/index.md index e086bff4..20979edd 100644 --- a/docs/chapter_array_and_linkedlist/index.md +++ b/docs/chapter_array_and_linkedlist/index.md @@ -2,6 +2,6 @@
-![数组与链表](../assets/covers/chapter_array_and_linkedlist.jpg){ width="70%" } +![数组与链表](../assets/covers/chapter_array_and_linkedlist.jpg){ width="600" }
diff --git a/docs/chapter_backtracking/index.md b/docs/chapter_backtracking/index.md index ea4d12d5..ef432234 100644 --- a/docs/chapter_backtracking/index.md +++ b/docs/chapter_backtracking/index.md @@ -2,6 +2,6 @@
-![回溯](../assets/covers/chapter_backtracking.jpg){ width="70%" } +![回溯](../assets/covers/chapter_backtracking.jpg){ width="600" }
diff --git a/docs/chapter_computational_complexity/index.md b/docs/chapter_computational_complexity/index.md index 54af4cbd..b042b9d7 100644 --- a/docs/chapter_computational_complexity/index.md +++ b/docs/chapter_computational_complexity/index.md @@ -2,6 +2,6 @@
-![复杂度](../assets/covers/chapter_complexity_analysis.jpg){ width="70%" } +![复杂度](../assets/covers/chapter_complexity_analysis.jpg){ width="600" }
diff --git a/docs/chapter_data_structure/index.md b/docs/chapter_data_structure/index.md index 1f5d9eec..96bafde9 100644 --- a/docs/chapter_data_structure/index.md +++ b/docs/chapter_data_structure/index.md @@ -2,6 +2,6 @@
-![数据结构](../assets/covers/chapter_data_structure.jpg){ width="70%" } +![数据结构](../assets/covers/chapter_data_structure.jpg){ width="600" }
diff --git a/docs/chapter_data_structure/number_encoding.md b/docs/chapter_data_structure/number_encoding.md index 360f5360..55760809 100644 --- a/docs/chapter_data_structure/number_encoding.md +++ b/docs/chapter_data_structure/number_encoding.md @@ -88,25 +88,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/docs/chapter_divide_and_conquer/index.md b/docs/chapter_divide_and_conquer/index.md index d9afa817..8340ae9c 100644 --- a/docs/chapter_divide_and_conquer/index.md +++ b/docs/chapter_divide_and_conquer/index.md @@ -2,6 +2,6 @@
-![分治](../assets/covers/chapter_divide_and_conquer.jpg){ width="70%" } +![分治](../assets/covers/chapter_divide_and_conquer.jpg){ width="600" }
diff --git a/docs/chapter_dynamic_programming/index.md b/docs/chapter_dynamic_programming/index.md index cb24d496..515097e5 100644 --- a/docs/chapter_dynamic_programming/index.md +++ b/docs/chapter_dynamic_programming/index.md @@ -2,6 +2,6 @@
-![动态规划](../assets/covers/chapter_dynamic_programming.jpg){ width="70%" } +![动态规划](../assets/covers/chapter_dynamic_programming.jpg){ width="600" }
diff --git a/docs/chapter_graph/index.md b/docs/chapter_graph/index.md index b1647780..d13458c0 100644 --- a/docs/chapter_graph/index.md +++ b/docs/chapter_graph/index.md @@ -2,6 +2,6 @@
-![图](../assets/covers/chapter_graph.jpg){ width="70%" } +![图](../assets/covers/chapter_graph.jpg){ width="600" }
diff --git a/docs/chapter_greedy/index.md b/docs/chapter_greedy/index.md index 209403f0..a6abfa6c 100644 --- a/docs/chapter_greedy/index.md +++ b/docs/chapter_greedy/index.md @@ -2,6 +2,6 @@
-![贪心](../assets/covers/chapter_greedy.jpg){ width="70%" } +![贪心](../assets/covers/chapter_greedy.jpg){ width="600" }
diff --git a/docs/chapter_hashing/index.md b/docs/chapter_hashing/index.md index 029b261b..61dea6a7 100644 --- a/docs/chapter_hashing/index.md +++ b/docs/chapter_hashing/index.md @@ -2,6 +2,6 @@
-![散列表](../assets/covers/chapter_hashing.jpg){ width="70%" } +![散列表](../assets/covers/chapter_hashing.jpg){ width="600" }
diff --git a/docs/chapter_heap/index.md b/docs/chapter_heap/index.md index ef2deb57..3ade71e3 100644 --- a/docs/chapter_heap/index.md +++ b/docs/chapter_heap/index.md @@ -2,6 +2,6 @@
-![堆](../assets/covers/chapter_heap.jpg){ width="70%" } +![堆](../assets/covers/chapter_heap.jpg){ width="600" }
diff --git a/docs/chapter_introduction/index.md b/docs/chapter_introduction/index.md index f8441fd2..3b317f1d 100644 --- a/docs/chapter_introduction/index.md +++ b/docs/chapter_introduction/index.md @@ -2,6 +2,6 @@
-![初识算法](../assets/covers/chapter_introduction.jpg){ width="70%" } +![初识算法](../assets/covers/chapter_introduction.jpg){ width="600" }
diff --git a/docs/chapter_preface/index.md b/docs/chapter_preface/index.md index d6e0462e..5a91e25d 100644 --- a/docs/chapter_preface/index.md +++ b/docs/chapter_preface/index.md @@ -2,6 +2,6 @@
-![前言](../assets/covers/chapter_preface.jpg){ width="70%" } +![前言](../assets/covers/chapter_preface.jpg){ width="600" }
diff --git a/docs/chapter_searching/index.md b/docs/chapter_searching/index.md index 82f223cc..3bc7b41f 100644 --- a/docs/chapter_searching/index.md +++ b/docs/chapter_searching/index.md @@ -2,6 +2,6 @@
-![搜索](../assets/covers/chapter_searching.jpg){ width="70%" } +![搜索](../assets/covers/chapter_searching.jpg){ width="600" }
diff --git a/docs/chapter_sorting/index.md b/docs/chapter_sorting/index.md index b1d8483d..7b797c40 100644 --- a/docs/chapter_sorting/index.md +++ b/docs/chapter_sorting/index.md @@ -2,6 +2,6 @@
-![排序](../assets/covers/chapter_sorting.jpg){ width="70%" } +![排序](../assets/covers/chapter_sorting.jpg){ width="600" }
diff --git a/docs/chapter_stack_and_queue/index.md b/docs/chapter_stack_and_queue/index.md index 7d86a78b..1c845b75 100644 --- a/docs/chapter_stack_and_queue/index.md +++ b/docs/chapter_stack_and_queue/index.md @@ -2,6 +2,6 @@
-![栈与队列](../assets/covers/chapter_stack_and_queue.jpg){ width="70%" } +![栈与队列](../assets/covers/chapter_stack_and_queue.jpg){ width="600" }
diff --git a/docs/chapter_tree/index.md b/docs/chapter_tree/index.md index 3d773a84..37553c92 100644 --- a/docs/chapter_tree/index.md +++ b/docs/chapter_tree/index.md @@ -2,6 +2,6 @@
-![树](../assets/covers/chapter_tree.jpg){ width="70%" } +![树](../assets/covers/chapter_tree.jpg){ width="600" }