I am trying to read a hex float value through std::cin
. However, it just reads in 0
. Here is my code so far:
#include <iomanip>
#include <iostream>
int main() {
double f = 0.0;
std::cout << ">";
std::cin >> std::hexfloat >> f;
std::cout << "Entered: " << f << std::endl;
return 0;
}
This will result in:
>0x1.921fb5p+1
Entered:0.0
Or if I exclude the 0x
:
>1.921fb5p+1
Entered:1.921
I am using g++ 7.0.1 and adding the compiler flag -std=c++11
on Ubuntu 17.