我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

最大浮线宽度

In go, the statement

fmt.Sprintf("%4.3f", 18.8836)

Will return

18.883

Is there a way of making the return value

18.88

In other words, is there a way to make the 4 apply to the whole width of the number and not just the decimal portion?

You can accomplish this with %g:

fmt.Printf("%.4g
", 18.8836)

https://play.golang.org/p/accWeNXG9V

近期文章

  • 将CURL转换为Golang代码
  • Golang Unmarshal切片的int切片
  • Golang,在Linux中加载Windows DLL
  • 如何使用sqlx进行LEFT JOIN查询?
  • 非常零星的Go HTTP错误:多个响应。WriteHeader调用
  • 在IntelliJ中导入Go项目不起作用
  • 解析Github的access_token响应
  • 如何在golang中找到(2,3或可能的话n)维切片的尺寸并验证其是否为矩阵?
  • 为什么goroutines没有`.join`操作?
  • Go具有模板语言吗?
  • 面向对象的实现
  • 去将reflect.Value从字符串转换为int
  • 错误的GET页面请求
  • 如何解决函数中的Go数组大小
  • 如何编写插入golang代码?
  • 将unicode字符存储在golang中
  • goroutine或多线程在golang中不起作用
  • 如何在Go中格式化此字符串
  • Archlinux:golang不能使用go build
  • 在GO中将字符串转换为函数名称? [重复]

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华