我有一个字符串,例如“3F800000”。
这是 float 1.0 的十六进制表示 只是我似乎找不到任何方便的方法在 C++ 中进行这种转换。有什么建议吗?
最佳答案
假设 32 位 int
和 float
,
unsigned int x;
std::stringstream ss;
ss << std::hex << "3F800000";
ss >> x;
return reinterpret_cast<float&>(x);
关于c++ - 转换 - 在 C++ 中 float 的 ASCII 十六进制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5031995/