当前位置:网站首页>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边栏推荐
- Pytest (5) - assertion
- The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
- Character painting, I use characters to draw a Bing Dwen Dwen
- 2021 Li Hongyi machine learning (1): basic concepts
- openresty ngx_ Lua execution phase
- ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience
- Ask, does this ADB MySQL support sqlserver?
- Qrcode: generate QR code from text
- el-select,el-option下拉选择框
- 问题解决:AttributeError: ‘NoneType‘ object has no attribute ‘append‘
猜你喜欢
Design and implementation of campus epidemic prevention and control system based on SSM
Design and practice of kubernetes cluster and application monitoring scheme
Design and implementation of kindergarten management system
Spark SQL learning bullet 2
2021 Li Hongyi machine learning (3): what if neural network training fails
Avoid material "minefields"! Play with super high conversion rate
Tiny series rendering tutorial
Tencent cloud, realize image upload
Why are there fewer and fewer good products produced by big Internet companies such as Tencent and Alibaba?
【LeetCode】222. The number of nodes of a complete binary tree (2 mistakes)
随机推荐
Privatization lightweight continuous integration deployment scheme -- 01 environment configuration (Part 1)
Master Fur
Apache Web page security optimization
Scientific research: are women better than men?
Anchor free series network yolox source code line by line explanation four (a total of ten, ensure line by line explanation, after reading, you can change the network at will, not just as a participan
Single box check box
College Students' innovation project management system
Spark SQL learning bullet 2
Good documentation
Port, domain name, protocol.
Learn game model 3D characters, come out to find a job?
【微服务|SCG】Filters的33种用法
Pat grade a 1119 pre- and post order traversals (30 points)
Structure of ViewModel
Design and implementation of campus epidemic prevention and control system based on SSM
问题解决:AttributeError: ‘NoneType‘ object has no attribute ‘append‘
LeetCode 314. Binary tree vertical order traversal - Binary Tree Series Question 6
1.五层网络模型
Azkaban概述
Hot knowledge of multithreading (I): introduction to ThreadLocal and underlying principles