C++ 使用std::hexfloat进行读写

C++ 使用std::hexfloat进行读写,c++,floating-point,iostream,iomanip,C++,Floating Point,Iostream,Iomanip,这段代码在我的机器上打印了0,但我希望0.3。发生了什么?我在最新的ArchLinux上使用g++6.3.1。编译标志似乎不可用 #include <iostream> #include <sstream> int main() { std::stringstream s; s << std::hexfloat << 0.3 << std::endl; double d = -1.0; while(s &

这段代码在我的机器上打印了
0
,但我希望
0.3
。发生了什么?我在最新的ArchLinux上使用g++6.3.1。编译标志似乎不可用

#include <iostream>
#include <sstream>
int main() {
    std::stringstream s;
    s << std::hexfloat << 0.3 << std::endl;
    double d = -1.0;
    while(s >> std::hexfloat >> d)
        std::cout << d << std::endl;
}
#包括
#包括
int main(){
std::strings;
s>d)

std::cout使用
double d=std::strod(s.str().c_str(),NULL);
作为解决方法。这似乎是一个bug。

运行提供的代码,我得到
0.3
作为输出。对我来说也是一个bug。这是一个bug,但不在gcc中:请参阅。