I have a float representation stored in an unsigned __int32. I know that you can reconstruct the number byte shifting, just as instructed in the answer of this question:
Convert int to float in C (no casting)
I want to avoid the shifting, multiplications and sums and just reinterpret the bits. I tried the Wikipedia example for IEEE 754 single precision entry but the reinterpretation results in a 0.
Here's my code:
unsigned __int32 integer = 0;
unsigned __int32 mask = 0;
mask = mask + 1 << 30;
mask = mask + 1 << 29;
mask = mask + 1 << 28;
mask = mask + 1 << 27;
mask = mask + 1 << 26;
mask = mask + 1 << 22;
integer = integer ^ mask;
printf("%ld %d\n", integer, sizeof(__int32));
float* decimal = reinterpret_cast<float*>(&integer);
printf("%f", *decimal);
return 0;