#include <iostream> int main() { float x; *(unsigned int *)&x = 0x4144CCCC; std::cout << x << std::endl; *(unsigned int *)&x = 0x40A00000; std::cout << x << std::endl; }
#include <iostream> #include <cmath> using namespace std; double ToDouble(unsigned int tal) { int Sign = tal & 0x80000000U ? -1 : 1; int E = (tal & 0x7F800000) >> 23; unsigned int F = tal & 0x7FFFFF; return Sign*(1.0 + double(F)/0x7FFFFF)*pow(2.0, E - 127); } int main() { cout << ToDouble(0x4144CCCC) << endl; cout << ToDouble(0x40A00000) << endl; }