summaryrefslogtreecommitdiff
path: root/devdocs/c/numeric%2Fmath%2Fscalbn.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/c/numeric%2Fmath%2Fscalbn.html
new repository
Diffstat (limited to 'devdocs/c/numeric%2Fmath%2Fscalbn.html')
-rw-r--r--devdocs/c/numeric%2Fmath%2Fscalbn.html99
1 files changed, 99 insertions, 0 deletions
diff --git a/devdocs/c/numeric%2Fmath%2Fscalbn.html b/devdocs/c/numeric%2Fmath%2Fscalbn.html
new file mode 100644
index 00000000..0a6b35c7
--- /dev/null
+++ b/devdocs/c/numeric%2Fmath%2Fscalbn.html
@@ -0,0 +1,99 @@
+ <h1 id="firstHeading" class="firstHeading">scalbn, scalbnf, scalbnl, scalbln, scalblnf, scalblnl</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;math.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">float scalbnf( float arg, int exp );</pre>
+</td> <td> (1) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">double scalbn( double arg, int exp );</pre>
+</td> <td> (2) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">long double scalbnl( long double arg, int exp );</pre>
+</td> <td> (3) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;tgmath.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">#define scalbn( arg, exp )</pre>
+</td> <td> (4) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;math.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">float scalblnf( float arg, long exp );</pre>
+</td> <td> (5) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">double scalbln( double arg, long exp );</pre>
+</td> <td> (6) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">long double scalblnl( long double arg, long exp );</pre>
+</td> <td> (7) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;tgmath.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">#define scalbln( arg, exp )</pre>
+</td> <td> (8) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> </table> <div class="t-li1">
+<span class="t-li">1-3,5-7)</span> Multiplies a floating point value <code>arg</code> by <code><a href="../../types/limits" title="c/types/limits">FLT_RADIX</a></code> raised to power <code><a href="http://en.cppreference.com/w/c/numeric/math/exp"><span class="kw657">exp</span></a></code>.</div> <div class="t-li1">
+<span class="t-li">4,8)</span> Type-generic macros: If <code>arg</code> has type <code>long double</code>, <code>scalbnl</code> or <code>scalblnl</code> is called. Otherwise, if <code>arg</code> has integer type or the type <code>double</code>, <code>scalbn</code> or <code>scalbln</code> is called. Otherwise, <code>scalbnf</code> or <code>scalblnf</code> is called, respectively.</div> <h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> arg </td> <td> - </td> <td> floating point value </td>
+</tr> <tr class="t-par"> <td> exp </td> <td> - </td> <td> integer value </td>
+</tr>
+</table> <h3 id="Return_value"> Return value</h3> <p>If no errors occur, <code>arg</code> multiplied by <code><a href="../../types/limits" title="c/types/limits">FLT_RADIX</a></code> to the power of <code><a href="http://en.cppreference.com/w/c/numeric/math/exp"><span class="kw657">exp</span></a></code> (arg×FLT_RADIX<sup class="t-su">exp</sup>) is returned.</p>
+<p>If a range error due to overflow occurs, <code><a href="huge_val" title="c/numeric/math/HUGE VAL">±HUGE_VAL</a></code>, <code>±HUGE_VALF</code>, or <code>±HUGE_VALL</code> is returned.</p>
+<p>If a range error due to underflow occurs, the correct result (after rounding) is returned.</p>
+<h3 id="Error_handling"> Error handling</h3> <p>Errors are reported as specified in <a href="math_errhandling" title="c/numeric/math/math errhandling"><code>math_errhandling</code></a>.</p>
+<p>If the implementation supports IEEE floating-point arithmetic (IEC 60559),</p>
+<ul>
+<li> Unless a range error occurs, <code><a href="../fenv/fe_exceptions" title="c/numeric/fenv/FE exceptions">FE_INEXACT</a></code> is never raised (the result is exact). </li>
+<li> Unless a range error occurs, the <a href="../fenv/fe_round" title="c/numeric/fenv/FE round">current rounding mode</a> is ignored. </li>
+<li> If <code>arg</code> is ±0, it is returned, unmodified. </li>
+<li> If <code>arg</code> is ±∞, it is returned, unmodified. </li>
+<li> If <code><a href="http://en.cppreference.com/w/c/numeric/math/exp"><span class="kw657">exp</span></a></code> is 0, then <code>arg</code> is returned, unmodified. </li>
+<li> If <code>arg</code> is NaN, NaN is returned. </li>
+</ul> <h3 id="Notes"> Notes</h3> <p>On binary systems (where <code><a href="../../types/limits" title="c/types/limits">FLT_RADIX</a></code> is <code>2</code>), <code>scalbn</code> is equivalent to <code><a href="ldexp" title="c/numeric/math/ldexp">ldexp</a></code>.</p>
+<p>Although <code>scalbn</code> and <code>scalbln</code> are specified to perform the operation efficiently, on many implementations they are less efficient than multiplication or division by a power of two using arithmetic operators.</p>
+<p>The <code>scalbln</code> function is provided because the factor required to scale from the smallest positive floating-point value to the largest finite one may be greater than <code>32767</code>, the standard-guaranteed <code><a href="../../types/limits" title="c/types/limits">INT_MAX</a></code>. In particular, for the 80-bit <code>long double</code>, the factor is <code>32828</code>.</p>
+<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;errno.h&gt;
+#include &lt;fenv.h&gt;
+#include &lt;float.h&gt;
+#include &lt;math.h&gt;
+#include &lt;stdio.h&gt;
+
+// #pragma STDC FENV_ACCESS ON
+
+int main(void)
+{
+ printf("scalbn(7, -4) = %f\n", scalbn(7, -4));
+ printf("scalbn(1, -1074) = %g (minimum positive subnormal double)\n",
+ scalbn(1, -1074));
+ printf("scalbn(nextafter(1,0), 1024) = %g (largest finite double)\n",
+ scalbn(nextafter(1,0), 1024));
+
+ // special values
+ printf("scalbn(-0, 10) = %f\n", scalbn(-0.0, 10));
+ printf("scalbn(-Inf, -1) = %f\n", scalbn(-INFINITY, -1));
+
+ // error handling
+ errno = 0; feclearexcept(FE_ALL_EXCEPT);
+ printf("scalbn(1, 1024) = %f\n", scalbn(1, 1024));
+ if (errno == ERANGE)
+ perror(" errno == ERANGE");
+ if (fetestexcept(FE_OVERFLOW))
+ puts(" FE_OVERFLOW raised");
+}</pre></div> <p>Possible output:</p>
+<div class="text source-text"><pre data-language="c">scalbn(7, -4) = 0.437500
+scalbn(1, -1074) = 4.94066e-324 (minimum positive subnormal double)
+scalbn(nextafter(1,0), 1024) = 1.79769e+308 (largest finite double)
+scalbn(-0, 10) = -0.000000
+scalbn(-Inf, -1) = -inf
+scalbn(1, 1024) = inf
+ errno == ERANGE: Numerical result out of range
+ FE_OVERFLOW raised</pre></div> </div> <h3 id="References"> References</h3> <ul>
+<li> C23 standard (ISO/IEC 9899:2023): </li>
+<ul>
+<li> 7.12.6.13 The scalbn functions (p: TBD) </li>
+<li> 7.25 Type-generic math &lt;tgmath.h&gt; (p: TBD) </li>
+<li> F.10.3.13 The scalbn functions (p: TBD) </li>
+</ul>
+<li> C17 standard (ISO/IEC 9899:2018): </li>
+<ul>
+<li> 7.12.6.13 The scalbn functions (p: TBD) </li>
+<li> 7.25 Type-generic math &lt;tgmath.h&gt; (p: TBD) </li>
+<li> F.10.3.13 The scalbn functions (p: TBD) </li>
+</ul>
+<li> C11 standard (ISO/IEC 9899:2011): </li>
+<ul>
+<li> 7.12.6.13 The scalbn functions (p: 247) </li>
+<li> 7.25 Type-generic math &lt;tgmath.h&gt; (p: 373-375) </li>
+<li> F.10.3.13 The scalbn functions (p: 523) </li>
+</ul>
+<li> C99 standard (ISO/IEC 9899:1999): </li>
+<ul>
+<li> 7.12.6.13 The scalbn functions (p: 228) </li>
+<li> 7.22 Type-generic math &lt;tgmath.h&gt; (p: 335-337) </li>
+<li> F.9.3.13 The scalbn functions (p: 460) </li>
+</ul>
+</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="frexp" title="c/numeric/math/frexp"> <span class="t-lines"><span>frexp</span><span>frexpf</span><span>frexpl</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> breaks a number into significand and a power of <code>2</code> <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="ldexp" title="c/numeric/math/ldexp"> <span class="t-lines"><span>ldexp</span><span>ldexpf</span><span>ldexpl</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> multiplies a number by <code>2</code> raised to a power <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/numeric/math/scalbn" title="cpp/numeric/math/scalbn">C++ documentation</a></span> for <code>scalbn</code> </td>
+</tr> </table> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
+ <a href="https://en.cppreference.com/w/c/numeric/math/scalbn" class="_attribution-link">https://en.cppreference.com/w/c/numeric/math/scalbn</a>
+ </p>
+</div>