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 关注
- 99 浏览
添加回答
举报
0/150
提交
取消