<divclass="line"><aid="l00011"name="l00011"></a><spanclass="lineno"> 11</span><spanclass="comment">// Redistribution and use in source and binary forms, with or without</span></div>
<divclass="line"><aid="l00012"name="l00012"></a><spanclass="lineno"> 12</span><spanclass="comment">// modification, are permitted provided that the following conditions</span></div>
<divclass="line"><aid="l00013"name="l00013"></a><spanclass="lineno"> 13</span><spanclass="comment">// are met:</span></div>
<divclass="line"><aid="l00015"name="l00015"></a><spanclass="lineno"> 15</span><spanclass="comment">// 1. Redistributions of source code must retain the above copyright</span></div>
<divclass="line"><aid="l00016"name="l00016"></a><spanclass="lineno"> 16</span><spanclass="comment">// notice, this list of conditions and the following disclaimer.</span></div>
<divclass="line"><aid="l00018"name="l00018"></a><spanclass="lineno"> 18</span><spanclass="comment">// 2. Redistributions in binary form must reproduce the above copyright</span></div>
<divclass="line"><aid="l00019"name="l00019"></a><spanclass="lineno"> 19</span><spanclass="comment">// notice, this list of conditions and the following disclaimer in the</span></div>
<divclass="line"><aid="l00020"name="l00020"></a><spanclass="lineno"> 20</span><spanclass="comment">// documentation and/or other materials provided with the distribution.</span></div>
<divclass="line"><aid="l00022"name="l00022"></a><spanclass="lineno"> 22</span><spanclass="comment">// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span></div>
<divclass="line"><aid="l00023"name="l00023"></a><spanclass="lineno"> 23</span><spanclass="comment">// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span></div>
<divclass="line"><aid="l00024"name="l00024"></a><spanclass="lineno"> 24</span><spanclass="comment">// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span></div>
<divclass="line"><aid="l00025"name="l00025"></a><spanclass="lineno"> 25</span><spanclass="comment">// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span></div>
<divclass="line"><aid="l00026"name="l00026"></a><spanclass="lineno"> 26</span><spanclass="comment">// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span></div>
<divclass="line"><aid="l00027"name="l00027"></a><spanclass="lineno"> 27</span><spanclass="comment">// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span></div>
<divclass="line"><aid="l00028"name="l00028"></a><spanclass="lineno"> 28</span><spanclass="comment">// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span></div>
<divclass="line"><aid="l00029"name="l00029"></a><spanclass="lineno"> 29</span><spanclass="comment">// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span></div>
<divclass="line"><aid="l00030"name="l00030"></a><spanclass="lineno"> 30</span><spanclass="comment">// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span></div>
<divclass="line"><aid="l00031"name="l00031"></a><spanclass="lineno"> 31</span><spanclass="comment">// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span></div>
<divclass="line"><aid="l00032"name="l00032"></a><spanclass="lineno"> 32</span><spanclass="comment">// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span></div>
<divclass="line"><aid="l00034"name="l00034"></a><spanclass="lineno"> 34</span><spanclass="comment">/* Compute exponential base e minus 1. Maximum ulp error = 0.997458</span></div>
<divclass="line"><aid="l00036"name="l00036"></a><spanclass="lineno"> 36</span><spanclass="comment"> i = rint(a/log(2)), f = a-i*log(2). Then expm1(a) = 2**i * (expm1(f)+1) - 1.</span></div>
<divclass="line"><aid="l00037"name="l00037"></a><spanclass="lineno"> 37</span><spanclass="comment"> Compute r = expm1(f). Then expm1(a)= 2 * (0.5 * 2**i * r + 0.5 * 2**i - 0.5).</span></div>
<divclass="line"><aid="l00038"name="l00038"></a><spanclass="lineno"> 38</span><spanclass="comment"> With t = 0.5*2**i, expm1(a) = 2*(r * t + t-0.5). However, for best accuracy,</span></div>
<divclass="line"><aid="l00039"name="l00039"></a><spanclass="lineno"> 39</span><spanclass="comment"> when i == 1, expm1(a)= 2*(r + 0.5), and when i == 0, expm1(a) = r.</span></div>
<divclass="line"><aid="l00041"name="l00041"></a><spanclass="lineno"> 41</span><spanclass="comment"> NOTE: Scale factor b is only applied if i < 0 or i > 1 (should be power of 2)</span></div>
<divclass="line"><aid="l00043"name="l00043"></a><spanclass="lineno"><aclass="line"href="expm1f_8h.html#adf20e03405fba634ca8d01acac24592e"> 43</a></span><spanclass="keywordtype">float</span><aclass="code hl_function"href="expm1f_8h.html#adf20e03405fba634ca8d01acac24592e">expm1f_scaled_unchecked</a>(<spanclass="keywordtype">float</span> a, <spanclass="keywordtype">float</span> b) {</div>
<divclass="line"><aid="l00053"name="l00053"></a><spanclass="lineno"> 53</span><spanclass="comment">// approximate r = exp(f)-1 on interval [-log(2)/2, +log(2)/2]</span></div>
<divclass="line"><aid="l00054"name="l00054"></a><spanclass="lineno"> 54</span> s = <aclass="code hl_variable"href="types_2bf16_8h.html#af900396d7b72ff2a7002e8befe8cf8f1">f</a> * <aclass="code hl_variable"href="types_2bf16_8h.html#af900396d7b72ff2a7002e8befe8cf8f1">f</a>;</div>
<divclass="line"><aid="l00055"name="l00055"></a><spanclass="lineno"> 55</span><spanclass="keywordflow">if</span> (a == 0.0f)</div>
<divclass="line"><aid="l00056"name="l00056"></a><spanclass="lineno"> 56</span> s = a; <spanclass="comment">// ensure -0 is passed through</span></div>
<divclass="line"><aid="l00079"name="l00079"></a><spanclass="lineno"> 79</span><spanclass="comment">/* Compute exponential base e minus 1. max ulp err = 0.99746 */</span></div>
<divclass="line"><aid="l00080"name="l00080"></a><spanclass="lineno"><aclass="line"href="expm1f_8h.html#a87f66d30e185950f42ce3641783cdc40"> 80</a></span><spanclass="keywordtype">float</span><aclass="code hl_function"href="expm1f_8h.html#a87f66d30e185950f42ce3641783cdc40">expm1f</a>(<spanclass="keywordtype">float</span> a) {</div>
<divclass="line"><aid="l00083"name="l00083"></a><spanclass="lineno"> 83</span> r = <aclass="code hl_function"href="expm1f_8h.html#adf20e03405fba634ca8d01acac24592e">expm1f_scaled_unchecked</a>(a, 1.0f);</div>
<divclass="line"><aid="l00084"name="l00084"></a><spanclass="lineno"> 84</span><spanclass="comment">/* handle severe overflow and underflow */</span></div>