您的位置 首页 golang

浮点数格式化输出的原理是什么?

 

fmt.Printf("1.8350 =>  %.2f\n",float64(1.835))
fmt.Printf("1.8450 =>  %.2f\n",float64(1.845))
fmt.Printf("5.8350 =>  %.2f\n",float64(5.835))
fmt.Printf("5.8450 =>  %.2f\n",float64(5.845))
fmt.Printf("7.8350 =>  %.2f\n",float64(7.835))
fmt.Printf("7.8450 =>  %.2f\n",float64(7.845))
fmt.Printf("8.8350 =>  %.2f\n",float64(8.835))
fmt.Printf("8.8450 =>  %.2f\n",float64(8.845))
fmt.Printf("9.8350 =>  %.2f\n",float64(9.835))
fmt.Printf("9.8450 =>  %.2f\n",float64(9.845))

输出结果:

1.8350 =>  1.83
1.8450 =>  1.84
5.8350 =>  5.83
5.8450 =>  5.84
7.8350 =>  7.83
7.8450 =>  7.84
8.8350 =>  8.84
8.8450 =>  8.85

9.8350 =>  9.84
9.8450 =>  9.85

为什么有时进位有时没有


文章来源:智云一二三科技

文章标题:浮点数格式化输出的原理是什么?

文章地址:https://www.zhihuclub.com/119.shtml

关于作者: 智云科技

热门文章

发表回复

您的电子邮箱地址不会被公开。

网站地图