float f = 12.5;
unsigned int _f = *reinterpret_cast<int*>(&f);
std::cout << _f << std::endl; // result: 1095237632
Run Code Online (Sandbox Code Playgroud)
有人可以解释一下这种铸造的原理吗?代表_f什么?
编辑
所以我1095237632转换为二进制后得到的这个数字是0b1000001010010000000000000000000,这个二进制数字是12.5在IEEE-754中。我说对了吗?
c++ ×1