1 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

golang输出双精度浮点例子(Printf)的更多相关文章

  1. 把十进制数(long型)分别以二进制和十六进制形式输出,不能使用printf系列。

    编程实现:把十进制数(long型)分别以二进制和十六进制形式输出,不能使用printf系列. 实现了unsigned long型的转换. // 十进制转换为二进制,十进制数的每1bit转换为二进制的1 ...

  2. php输出语句 echo print printf print_r var_dump sprintf

    php的几种输出方式: echo 常用的输出语句,例如:echo 'helloworld!'; print() 输出语句,有返回值.例如:print('helloworld!'); 输出成功返回1,失 ...

  3. [例1.10]使用setw设置输出宽度的例子

    [例1.10]使用setw设置输出宽度的例子: #include <iostream> #include <iomanip> using namespace std; void ...

  4. Shell 格式化输出数字、字符串(printf)

    1.语法 printf打印格式字符串,解释'%'指令和'\'转义. 1.1.转义 printf使用时需要指定输出格式,输出后不换行. printf FORMAT [ARGUMENT] printf O ...

  5. PHP学习之输出字符串(echo,print,printf,printr和vardump)

    下面一一进行介绍. 1. echo echo 是PHP的一个关键字,它没有返回值.在写法上,它可以省略小括号.如下代码: 复制代码 代码如下: echo 'Test String'; echo('Te ...

  6. VC和VS系列(2005)编译器对双精度浮点溢出的处理

    作者:风影残烛 在还原代码的过程中.目前程序是采用VS2005(以上版本)写的. 我使用的是vc6.0,结果.在运算的时候.发现编译器对 // FpuTlxTest.cpp : 定义控制台应用程序的入 ...

  7. 如何改变输出方式(让printf输出结果保存到TXT文本中)

    查阅相关资料,汇总如下: #include <stdio.h> #include <stdlib.h> int main() { char money= 's'; char a ...

  8. PHP中输出字符串(echo,print,printf,print_r和var_dump)的区别【转载】

    php中常见的输出语句 echo()可以一次输出多个值,多个值之间用逗号分隔.echo是语言结构(language construct),而并不是真正的函数,因此不能作为表达式的一部分使用. prin ...

  9. golang flag包简单例子

    package main import ( "flag" "fmt" ) var workers int; func main() { flag.IntVar( ...

随机推荐

  1. SpringMVC拦截器执行流程

    1:MyInterceptor1.MyInterceptor2这2个拦截器都放行 MyInterceptor1......preHandleMyInterceptor2......preHandle ...

  2. oracle高级部分

    回顾 多表关联查询的方式 内连接 根据AB表关联的条件进行过滤查询,只保留满足条件数据 Select * from a,b where a.xxx=b.xxx; Select * from a inn ...

  3. Python字符编码和转码

    一:Python2 python2默认编码格式是ascii码,解释器解释代码时会将代码以及代码中的字符串等转换成ascii码再执行.这样会导致字符串输出或传输时,与当前环境编码格式不同的话会显示乱码. ...

  4. Leetcode——1. 两数之和

    难度: 简单 题目 Given an array of integers, return indices of the two numbers such that they add up to a s ...

  5. matplot 绘制定制饼图

    1.普通风格 代码 import matplotlib.pyplot as plt plt.rcParams['font.sans-serif'] = 'SimHei' # 使图形中的中文正常编码显示 ...

  6. 记一次wsl上的pip3安装失败问题 The following packages were automatically installed and are no longer required:

    转载请注明来源.https://www.cnblogs.com/sogeisetsu/.然后我的CSDNhttps://blog.csdn.net/suyues/article/details/103 ...

  7. mysql基础知识之数据类型与约束

    一.约束 作用: 保证数据的完整性和一致性表的设计 1.not null 和 default not null 是放在最后用来约束 前面 数据类型的 (在原有基础上本来可以主键后面可以为空,但是一旦在 ...

  8. windows server 2008 安装MySQL 8.0 遇到报错 1055 - Expression #1 of ORDER BY clause is not in GROUP BY

    mysql安装参考教程:https://blog.csdn.net/qq_37350706/article/details/81707862 安装完毕后 执行sql语句 SELECT * FROM c ...

  9. LOJ 3119: 洛谷 P5400: 「CTS2019 | CTSC2019」随机立方体

    题目传送门:LOJ #3119. 题意简述: 题目说的很清楚了. 题解: 记恰好有 \(i\) 个极大的数的方案数为 \(\mathrm{cnt}[i]\),则答案为 \(\displaystyle\ ...

  10. 积性函数与Dirichlet卷积

    转载自https://oi-wiki.org/math/mobius/ 积性函数 定义 若 $gcd(x,y)=1$ 且 $f(xy)=f(x)f(y)$,则 $f(n)$ 为积性函数. 性质 若 $ ...