golang输出双精度浮点例子(Printf)
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
相关推荐
qingsongzdq 2020-02-01
Android开发CXY 2020-11-11
lpkwxl 2020-06-17
RealJianyuan 2020-06-14
pbyanglove 2020-06-09
徐建岗网络管理 2020-06-09
fengjing81 2020-06-06
lynjay 2020-06-02
wujingsheng0 2020-05-16
吴小伟 2020-05-09
sillion 2020-05-03
xiaobater 2020-05-01
ericasadun 2020-04-26
lynjay 2020-04-26
choupiaoyi 2020-04-26