如何在输出控制台中显示更多小数? [英] How do I display more decimals in the output console?

查看:58
本文介绍了如何在输出控制台中显示更多小数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想输出全精度的double值。但是,使用cout函数时,即使精度为15-16位左右,它也只显示前6位数字。

I want to output the value of a double in it's full precision. However, when using the cout function, it only displays the first 6 digits even though there is around 15-16 digits of precision.

如何让我的程序显示整个值,包括幅度(幂)分量?

How do I get my program to display the entire value, including the magnitude (power) component?

推荐答案

使用 setprecision()机械手:

http://www.cplusplus.com/reference/iostream/manipulators/setprecision/

您也可以使用 scientific 机械手来强制使用科学计数法:

You can also force scientific notation with the scientific manipulator:

http://www.cplusplus.com/reference/iostream/manipulators/scientific/

cout << scientific << setprecision(15) << my_number << endl;

这篇关于如何在输出控制台中显示更多小数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆