First, you have some data in a specific type like int here:
int x = 0x7fffffff0x7FFFFFFF: // ==nan in binary representation
Then you want to access the same variable as an other type like float: You can decide between
float y = reinterpret_cast<float&>(x);
//this This could only be used in cpp,C++. It looks like a function with template-parameters
or
float y = *(float*)&(x);
//this This could be used in cC and cppC++
BRIEF: itIt means that the same memory is used as a different type. So you could convert binary representations of floats as int type like above to floats. 0x80000000 is -0 for example (the mantissa and exponent are null but the sign, the msbMSb, is one. This also works for doubles and long doubles.
OPTIMIZE: I think reinterpret_cast would be optimized in many compilers, while the c-castingC casting is made by pointerarithmetic (the value must be copied to the memory, causebecause pointers couldn't point to cpu-CPU registers).
NOTE: In both cases you should save the castedcast value in a variable before cast! This macro could help:
#define asvar(x) ({decltype(x) __tmp__ = (x); __tmp__; })