I want to convert a hexadecimal string that is the memory dump of a float to float. I tried this code:
#include <iostream>
#include <string>
using namespace std;
int main() {
std::string hexString = "0x3f9d70a4";
float floatValue = std::stof(hexString, nullptr);
cout << floatValue;
}
But this program outputs 1.06728e+09 instead of 1.23
Any pointers on how to convert it appropriately in C++