GoatSucker 2019-12-08
package main import "fmt" func main() { var sum int = 17 var count int = 5 var mean float64 mean = float64(count) / float64(sum) fmt.Printf("mean 的值为: %f\n", mean) fmt.Printf("mean 的值为: %.10f\n", float64(mean)) fmt.Printf("mean 的值为: %.20f\n", float64(mean)) fmt.Printf("mean 的值为: %.30f\n", float64(mean)) fmt.Printf("mean 的值为: %.40f\n", float64(mean)) fmt.Printf("%e\n", 123400000.0) fmt.Printf("%E\n", 123400000.0) }
以上是代码,输出显示如下:
mean 的值为: 0.294118
mean 的值为: 0.2941176471
mean 的值为: 0.29411764705882353921
mean 的值为: 0.294117647058823539207850217281
mean 的值为: 0.2941176470588235392078502172807930037379
1.234000e+08
1.234000E+08