【发布时间】:2016-04-27 19:31:43
【问题描述】:
不使用科学计数法将double转为字符串,建议的方法是
std::ostringstream strStream;
strStream << std::fixed;
strStream << value;
std::string str = strStream.str();
如 Prevent scientific notation in ostream when using << with double & How do I convert a double into a string in C++?
我想将 double 转换为不带任何分隔符的字符串,并将点/句号作为小数点,即忽略语言环境。
根据ostringstream、std::fixed和showpoint的描述,我无法确定
- 小数点是否在当前语言环境中?和
- str()返回的字符串中是否会存在其他的分隔符(如千位分组)?
如果它按照当前的语言环境,有什么方法可以覆盖 - 它总是点/句号作为小数点并且没有分组?
【问题讨论】:
标签: c++ string double iostream