[英]configure linux out streams
There is an issue in Linux, that it has 0
and -0
. Linux中存在一个问题,它具有
0
和-0
。 This is because of Floating points, etc. I want to always ignore the -
before the 0
. 这是由于浮点数等原因。我想始终忽略
-
之前的0
。
Is there a way to configure the 'out stream' (to a file) or the working IDE/editor? 有没有一种方法可以配置“出流”(到文件)或有效的IDE /编辑器?
thank you 谢谢
If you are using C++, you may be able to create your own stream formatter specialization: 如果使用的是C ++,则可以创建自己的流格式化程序专业化:
Something like 就像是
class my_ostream : public std::ostream {
public:
my_ostream& operator<<( float f ) {
std::ostrstream oss;
oss << f;
if( oss.str() == "-0" ) f = fabs(f);
*this->std::ostream << f;
return *this;
}
};
You probably need to copy formatting from *this to the ostringstream. 您可能需要将格式从* this复制到ostringstream。
Note that I have created a wrapper type. 请注意,我已经创建了包装器类型。 You might be able simply to overload a specialization for
您也许可以简单地为
std::ostream& operator(<< std::ostream& os, float f )
and similarly for doubles, and other float types. 同样适用于双打和其他浮动类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.