开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜