小编tru*_*ans的帖子

如何在 Go 中获取精确的 float64 值?

我得到一个float64值43701.330694444441,在我调用strconv.ParseFloat(v, 64)函数后,结果是43701.33069444444。任何人都可以解决这个问题吗?

v := "43701.330694444441"

f, err := strconv.ParseFloat(v, 64)
if err != nil {
    return
}
fmt.Println(f) // it output 43701.33069444444, the tail '1' is missing.
Run Code Online (Sandbox Code Playgroud)

floating-point precision go

-1
推荐指数
1
解决办法
1242
查看次数

标签 统计

floating-point ×1

go ×1

precision ×1