I know the handy trick to cast float bits to ints and vice versa using *(int*)(&fNum) and its inverse, but what about when I want to cast non lvalue bits to a float.
for example, I can't think of a reason I would ever need to do this, but lets pretend I want to make a macro that generates a negative float, and I wrote the macro as follows:
and then lets say I want to call a function that accepts a float and I want to pass in whatever this function returns.Code://forgive me for any errors in this, its only an example #define MAKE_NEG_FLOAT(exp,mantissa) \ (0x80000000 | (((exp)&0x000000FF)<<23) | ((mantissa)&0x008FFFFF)
The MAKE_NEG_FLOAT macro resolves to an integer, and then the func will cast that to a float rather than converting it to a float with the same bits. My question is this: is there any way, given the setup or a similar setup of code, that would allow me to convert the non-lvalue integer return of a macro directly to a float without casting? Any hackish, crazy way would make me happy, as long as its quick to process and/or could be compiled out with a decent optimized compiler.Code:void func(float num); //... func( MAKE_NEG_FLOAT(10, 0) );