教程集 www.jiaochengji.com
教程集 >  Golang编程  >  golang教程  >  正文 浮点数格式化输出的原理是什么?

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

发布时间:2021-04-28   编辑:jiaochengji.com
教程集为您提供浮点数格式化输出的原理是什么?等资源,欢迎您收藏本站,我们将为您提供最新的浮点数格式化输出的原理是什么?资源

 

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

为什么有时进位有时没有


到此这篇关于“浮点数格式化输出的原理是什么?”的文章就介绍到这了,更多文章或继续浏览下面的相关文章,希望大家以后多多支持JQ教程网!

您可能感兴趣的文章:
PHP浮点数运算精度的问题
浮点数格式化输出的原理是什么?
CSS规范 闭合浮动元素介绍
在python中%是什么意思
%f在python中什么意思
php浮点相减不等于0
python中表达式4 0.5值的数据类型为?
正负小数点后两位浮点数实现原理及代码
PHP浮点数比较方法
python百分号什么意思

[关闭]
~ ~