当前位置:网站首页>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边栏推荐
- Zabbix
- openresty ngx_ Lua execution phase
- 1. Five layer network model
- 【微服务|SCG】Filters的33种用法
- Hot knowledge of multithreading (I): introduction to ThreadLocal and underlying principles
- Six stone programming: advantages of automated testing
- Design of KTV intelligent dimming system based on MCU
- Share the newly released web application development framework based on blazor Technology
- [Yu Yue education] National Open University spring 2019 0505-22t basic nursing reference questions
- El tree whether leaf node or not, the drop-down button is permanent
猜你喜欢

为什么腾讯阿里等互联网大厂诞生的好产品越来越少?

Flume configuration 4 - customize mysqlsource

Asemi rectifier bridge 2w10 parameters, 2w10 specifications, 2w10 characteristics

问题解决:AttributeError: ‘NoneType‘ object has no attribute ‘append‘
![[uc/os-iii] chapter 1.2.3.4 understanding RTOS](/img/33/1d94583a834060cc31cab36db09d6e.jpg)
[uc/os-iii] chapter 1.2.3.4 understanding RTOS

Elfk deployment

Sqoop命令

Yyds dry goods inventory intelligent fan based on CC2530 design

腾讯云,实现图片上传

Tencent cloud, realize image upload
随机推荐
Asp+access campus network goods trading platform
Mongodb common commands
Scientific research: are women better than men?
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
From task Run get return value - getting return value from task Run
Kotlin - coroutine
Why is this an undefined behavior- Why is this an undefined behavior?
Dart series: collection of best practices
【LeetCode】111. Minimum depth of binary tree (2 brushes of wrong questions)
Design of KTV intelligent dimming system based on MCU
平台入驻与独立部署优缺点对比
Structure of ViewModel
Idea inheritance relationship
[200 opencv routines] 99 Modified alpha mean filter
Design and practice of kubernetes cluster and application monitoring scheme
Kbp206-asemi rectifier bridge kbp206
LeetCode --- 1071. Great common divisor of strings problem solving Report
Utilisation simple de devtools
2022/02/13
el-select,el-option下拉选择框