当前位置:网站首页>How can we truncate the float64 type to a specific precision- How can we truncate float64 type to a particular precision?
How can we truncate the float64 type to a specific precision- How can we truncate float64 type to a particular precision?
2022-07-05 02:57:00 【Technology feast】
problem :
package mainimport ( "fmt" "strconv" )func main() { k := 10/3.0 i := fmt.Sprintf("%.2f", k) f,_ := strconv.ParseFloat(i, 2) fmt.Println(f)}I had to write the program above to decrease the precision of a go float64 variable to 2. In this case I was using both strconv and fmt. I have to write the above program to go float64 The accuracy of the variable is reduced to 2. under these circumstances , I used... At the same time strconv and fmt.Is there some other logical method by which it can be done? Is there any other logical method to complete ?
Solution :
Reference resources : https://stackoom.com/en/question/1FA9C边栏推荐
- D3js notes
- el-select,el-option下拉选择框
- Sqoop command
- Hot knowledge of multithreading (I): introduction to ThreadLocal and underlying principles
- 【微服务|SCG】Filters的33种用法
- 为什么腾讯阿里等互联网大厂诞生的好产品越来越少?
- Eight days of learning C language - while loop (embedded) (single chip microcomputer)
- d3js小记
- How to make OS X read bash_ Profile instead of Profile file - how to make OS X to read bash_ profile not . profile file
- Talk about the SQL server version of DTM sub transaction barrier function
猜你喜欢

【LeetCode】111. Minimum depth of binary tree (2 brushes of wrong questions)

丸子百度小程序详细配置教程,审核通过。

1. Five layer network model

Spark SQL learning bullet 2

Kbp206-asemi rectifier bridge kbp206

Learn game model 3D characters, come out to find a job?

Single box check box
![Acwing game 58 [End]](/img/16/c55e0a7aedc354f1c739637ed13a6b.png)
Acwing game 58 [End]

Avoid material "minefields"! Play with super high conversion rate

Linux安装Redis
随机推荐
Pat class a 1162 postfix expression
[Yu Yue education] National Open University autumn 2018 8109-22t (1) monetary and banking reference questions
Spark SQL learning bullet 2
Devtools的简单使用
Ask, does this ADB MySQL support sqlserver?
Zabbix
Tencent cloud, realize image upload
SQL injection exercise -- sqli Labs
腾讯云,实现图片上传
qrcode:将文本生成二维码
Why do you understand a16z? Those who prefer Web3.0 Privacy Infrastructure: nym
看 TDengine 社区英雄线上发布会,听 TD Hero 聊开发者传奇故事
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
Azkaban实战
2021 Li Hongyi machine learning (3): what if neural network training fails
返回二叉树中两个节点的最低公共祖先
端口,域名,协议。
Scientific research: are women better than men?
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
[200 opencv routines] 99 Modified alpha mean filter