title: Getting the exponent from a floating point in C
body: <p>I'm writing a function that will get the exponent of a floating point number (IEEE 754 standard) but for some reason when I use the right shift bitwise operator on the number it returns 0</p>
  
  <p>Here is the function</p>
  
  <pre><code>int get_exp (int x) 
  {
    return ( ((x &gt;&gt; 21) &amp; 255) -127 ); 
  }
  </code></pre>
  
  <p>I'm passing it 7.23 so the output should be 2, for some reason the (x >> 21) part returns 0 when it should actually be returning 129. The 255 is the mask I'm using to and (&amp;) with the exponent part of the floating point number.</p>