打印浮法或双科学非科学的 [英] Print float or double in non scientific notaion
本文介绍了打印浮法或双科学非科学的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果位数为7以上,则浮点数或双倍总是用科学记数法给出答案。像十进制数 10000000.5
它正在赋予 1e-08
的东西。我想知道是否可以打印 10000000.5
而不添加任何新的头文件。
Float or double always gives answer in scientific notation if number of digits are 7 or more. Like an decimal number 10000000.5
it is giving 1e-08
something. I am wondering if we can print 10000000.5
without adding any new header file.
推荐答案
如果您打印到 cout
,请使用
std::cout.setf( std::ios::fixed, std::ios::floatfield );
您可能还需要 std :: cout.precision(1)
设置小数点后的位数。
You might also want std::cout.precision(1)
to set the number of digits after the decimal point.
这篇关于打印浮法或双科学非科学的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文