I found the following code which calculates log2
of float x
:
union { float f; unsigned int i; } vx = { x };
float y = vx.i;
y *= 1.0 / (1 << 23);
y = y - 126.94269504f;
return y;
The f
parameter of union is initialized to input x
and then it uses i
? I can not understand how it uses something that is not initialized. And what vx.i
value is actually? Thank you.