当前位置:网站首页>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边栏推荐
- Flume configuration 4 - customize mysqlsource
- openresty ngx_ Lua variable operation
- Hmi-32- [motion mode] add light panel and basic information column
- 2022/02/13
- The database and recharge are gone
- ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience
- Ask, does this ADB MySQL support sqlserver?
- El select, El option drop-down selection box
- 【LeetCode】404. Sum of left leaves (2 brushes of wrong questions)
- Which common ports should the server open
猜你喜欢
![ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience](/img/22/08617736a8b943bc9c254aac60c8cb.jpg)
ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience

The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety

Design and implementation of high availability website architecture
![Moco V2 literature research [self supervised learning]](/img/bd/79b7b203ea064c65d143116c9f4dd0.jpg)
Moco V2 literature research [self supervised learning]

qrcode:将文本生成二维码

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

Pytest (5) - assertion

TCP security of network security foundation

Share the newly released web application development framework based on blazor Technology

Design and implementation of community hospital information system
随机推荐
Design of KTV intelligent dimming system based on MCU
Sqoop安装
Cut! 39 year old Ali P9, saved 150million
TCP security of network security foundation
Structure of ViewModel
Good documentation
2022/02/13
Three line by line explanations of the source code of anchor free series network yolox (a total of ten articles, which are guaranteed to be explained line by line. After reading it, you can change the
端口,域名,协议。
Daily question 2 12
Avoid material "minefields"! Play with super high conversion rate
Master Fur
Kotlin - 协程 Coroutine
Use UDP to send a JPEG image, and UPD will convert it into the mat format of OpenCV after receiving it
ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience
【LeetCode】111. Minimum depth of binary tree (2 brushes of wrong questions)
LeetCode146. LRU cache
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
D3js notes
SQL performance optimization skills