【问题标题】:how to avoid "exponent" format when printing double to stringstream将双精度打印到字符串流时如何避免“指数”格式
【发布时间】:2014-06-08 21:10:01
【问题描述】:

我以这种方式将 double 打印到 stringstream::

std::stringstream message;
message << sss[j]->stocks << '/' << std::setprecision(5) << sss[j]->profit << '/' << sss[j]->lastPrice;
std::cout << std::setw(30) << message.str();

sss[j]-&gt;profit 是双倍的。我希望它打印“没有 E”,但在输出中我仍然有这样的东西:

-560000/4.076e+005/0.7394

如何避免e

【问题讨论】:

标签: c++


【解决方案1】:

使用std::fixed

std::cout << std::fixed << sss[j]->stocks << std::endl;

顺便说一句,“e”来自所谓的科学符号。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-25
    • 1970-01-01
    • 2020-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-03
    相关资源
    最近更新 更多