C ++十进制输出格式 [英] C++ decimal output formatting
本文介绍了C ++十进制输出格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
通常的方法是使用一个区域设置为逗号的小数点分隔符。如果你的机器一般是这样配置的,那么你可以使用无名称的语言环境:
std :: cout.imbue (标准::区域设置( ));
std :: cout<< 12345.67;
i'm writing a double value to a file. The numeric value is written with a point as a decimal separator. I would like to use a comma. How i can do that?
解决方案
The usual way is to use a locale with the decimal separator set to the comma. If your machine is configured for that generally, you can probably just use the nameless locale for it:
std::cout.imbue(std::locale(""));
std::cout << 12345.67;
这篇关于C ++十进制输出格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文