Struggling with union output
<p>I'm trying to figure out this code for about an hour and still no luck.</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

int f(float f)
{
    union un {float f; int i;} u = {f};

    return (u.i&amp;0x7F800000) &gt;&gt; 23;
}

int main()
{
    printf("%d\n", f(1));

return 0;
}
</code></pre>

<p>I don't understand how this work, I've tried f(1), f(2), f(3), f(4) and of course getting the different results. I've also read a lot about unions and stuff. What I have noticed that when i delete 0x7F800000 from return, results will be the same. I wanna know how u.i is generated, obviously it is not some random garbage but also it is not one (1) from function argument. What is going on here, how does it work? </p>