当前位置:网站首页>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边栏推荐
- How to find hot projects in 2022? Dena community project progress follow-up, there is always a dish for you (1)
- 为什么腾讯阿里等互联网大厂诞生的好产品越来越少?
- Master Fur
- PHP cli getting input from user and then dumping into variable possible?
- Acwing game 58 [End]
- 腾讯云,实现图片上传
- Marubeni Baidu applet detailed configuration tutorial, approved.
- 2021 Li Hongyi machine learning (1): basic concepts
- Sqoop command
- When the low alcohol race track enters the reshuffle period, how can the new brand break the three major problems?
猜你喜欢
spoon插入更新oracle数据库,插了一部分提示报错Assertion botch: negative time
Mongodb common commands
Spoon inserts and updates the Oracle database, and some prompts are inserted with errors. Assertion botch: negative time
Character painting, I use characters to draw a Bing Dwen Dwen
IPv6 experiment
openresty ngx_lua執行階段
Port, domain name, protocol.
2. Common request methods
Flume配置4——自定义MYSQLSource
Design and implementation of community hospital information system
随机推荐
Last week's hot review (2.7-2.13)
Zabbix
Flume配置4——自定义MYSQLSource
Character painting, I use characters to draw a Bing Dwen Dwen
qrcode:将文本生成二维码
Utilisation simple de devtools
丸子百度小程序详细配置教程,审核通过。
Ask, does this ADB MySQL support sqlserver?
Avoid material "minefields"! Play with super high conversion rate
Azkaban overview
Apache Web page security optimization
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
Learn game model 3D characters, come out to find a job?
TCP security of network security foundation
Voice chip wt2003h4 B008 single chip to realize the quick design of intelligent doorbell scheme
Pytest (4) - test case execution sequence
ELK日志分析系统
Share the newly released web application development framework based on blazor Technology
问下,这个ADB mysql支持sqlserver吗?
【LeetCode】404. Sum of left leaves (2 brushes of wrong questions)