<h1 id="exponent">Exponent</h1><blockquote><p>Return an integer corresponding to the unbiased exponent of a <a href="https://en.wikipedia.org/wiki/IEEE_754-1985">single-precision floating-point number</a>.</p></blockquote><section class="usage"><h2 id="usage">Usage</h2><pre><code class="hljs language-javascript"><span class="hljs-keyword">var</span> exponentf = <span class="hljs-built_in">require</span>( <span class="hljs-string">'@stdlib/number/float32/base/exponent'</span> );
</code></pre><h4 id="exponentf-x-">exponentf( x )</h4><p>Returns an <code>integer</code> corresponding to the unbiased exponent of a <a href="https://en.wikipedia.org/wiki/IEEE_754-1985">single-precision floating-point number</a>.</p><pre><code class="hljs language-javascript"><span class="hljs-keyword">var</span> toFloat32 = <span class="hljs-built_in">require</span>( <span class="hljs-string">'@stdlib/number/float64/base/to-float32'</span> );

<span class="hljs-keyword">var</span> exp = exponentf( toFloat32( <span class="hljs-number">3.14e34</span> ) ); <span class="hljs-comment">// => 2^114 ~ 2.08e34</span>
<span class="hljs-comment">// returns 114</span>

exp = exponentf( toFloat32( <span class="hljs-number">3.14e-34</span> ) ); <span class="hljs-comment">//  => 2^-112 ~ 1.93e-34</span>
<span class="hljs-comment">// returns -112</span>

exp = exponentf( toFloat32( -<span class="hljs-number">3.14</span> ) );
<span class="hljs-comment">// returns 1</span>

exp = exponentf( <span class="hljs-number">0.0</span> );
<span class="hljs-comment">// returns -127</span>

exp = exponentf( <span class="hljs-literal">NaN</span> );
<span class="hljs-comment">// returns 128</span>
</code></pre></section><section class="examples"><h2 id="examples">Examples</h2><pre><code class="hljs language-javascript"><span class="hljs-keyword">var</span> randu = <span class="hljs-built_in">require</span>( <span class="hljs-string">'@stdlib/random/base/randu'</span> );
<span class="hljs-keyword">var</span> round = <span class="hljs-built_in">require</span>( <span class="hljs-string">'@stdlib/math/base/special/round'</span> );
<span class="hljs-keyword">var</span> pow = <span class="hljs-built_in">require</span>( <span class="hljs-string">'@stdlib/math/base/special/pow'</span> );
<span class="hljs-keyword">var</span> toFloat32 = <span class="hljs-built_in">require</span>( <span class="hljs-string">'@stdlib/number/float64/base/to-float32'</span> );
<span class="hljs-keyword">var</span> exponentf = <span class="hljs-built_in">require</span>( <span class="hljs-string">'@stdlib/number/float32/base/exponent'</span> );

<span class="hljs-keyword">var</span> frac;
<span class="hljs-keyword">var</span> exp;
<span class="hljs-keyword">var</span> x;
<span class="hljs-keyword">var</span> e;
<span class="hljs-keyword">var</span> i;

<span class="hljs-comment">// Generate random numbers and extract their exponents...</span>
<span class="hljs-keyword">for</span> ( i = <span class="hljs-number">0</span>; i &#x3C; <span class="hljs-number">100</span>; i++ ) {
    frac = randu() * <span class="hljs-number">10.0</span>;
    exp = round( randu()*<span class="hljs-number">44.0</span> ) - <span class="hljs-number">22</span>;
    x = frac * pow( <span class="hljs-number">10.0</span>, exp );
    x = toFloat32( x );
    e = exponentf( x );
    <span class="hljs-built_in">console</span>.log( <span class="hljs-string">'x: %d. unbiased exponent: %d.'</span>, x, e );
}
</code></pre></section><section class="related"></section><section class="links"></section>