根据这些文档 %g是%e for large exponents, %f otherwise. 但是,当我这样做时:
package main
import "fmt"
func main() {
var a float64 = 2.0
fmt.Printf("%f\n", a)
fmt.Printf("%e\n", a)
fmt.Printf("%g\n", a)
}
我得到:
2.000000
2.000000e+00
2
为什么输出%g不包含固定的小数位,如%e或%f?
一只斗牛犬
相关分类