conversion - ASCII hex to float in c++
I have a string containing, for example "3F800000".
This is a hexadeci开发者_运维百科mal representation of the float 1.0 Only I can't seem to find any convenient way of making this conversion in C++. Suggestions?
Assuming 32-bit int
and float
,
unsigned int x;
std::stringstream ss;
ss << std::hex << "3F800000";
ss >> x;
return reinterpret_cast<float&>(x);
精彩评论