package mainimport ( "fmt" "math")func main() { x, y := math.NaN(), math.MaxFloat64 fmt.Printf("%d\n", int(x)) fmt.Printf("%d\n", int(y))}那是我的測試代碼片段。當我使用 go1.14.2 運行上面的代碼時,結果是-9223372036854775808-9223372036854775808但是同樣的代碼在go1.17.2中運行,結果是09223372036854775807我搜索了類似的問題:Why Is uint64 of NaN and MaxFloat64 equal in Golang? ,上面說在不同的硬件環境下,math.NaN() 可能不同,但是我在我的 MacOS M1 系統中運行代碼,只是 golang 版本不同。為什么go1.14.2和go1.17.2結果不一樣?
- 1 回答
- 0 關注
- 92 瀏覽
添加回答
舉報
0/150
提交
取消