Skip to content

Commit a30f143

Browse files
authored
Update float 类型可以作为 map 的 key 吗.md
fmt.Println(math.Float64bits(2.4)) fmt.Println(math.Float64bits(2.400000000001)) 两个结果互换位置
1 parent 776b9df commit a30f143

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: map/float 类型可以作为 map 的 key 吗.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ func main() {
9595
```
9696

9797
```shell
98-
4612586738352864255
9998
4612586738352862003
99+
4612586738352864255
100100
4612586738352862003
101101
```
102102

@@ -154,4 +154,4 @@ hash(NAN) != hash(NAN)
154154

155155
因此向 map 中查找的 key 为 NAN 时,什么也查不到;如果向其中增加了 4 次 NAN,遍历会得到 4 个 NAN。
156156

157-
最后说结论:float 型可以作为 key,但是由于精度的问题,会导致一些诡异的问题,慎用之。
157+
最后说结论:float 型可以作为 key,但是由于精度的问题,会导致一些诡异的问题,慎用之。

0 commit comments

Comments
 (0)