summaryrefslogtreecommitdiff
path: root/devdocs/c/numeric%2Fmath%2Ffrexp.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/c/numeric%2Fmath%2Ffrexp.html')
-rw-r--r--devdocs/c/numeric%2Fmath%2Ffrexp.html79
1 files changed, 79 insertions, 0 deletions
diff --git a/devdocs/c/numeric%2Fmath%2Ffrexp.html b/devdocs/c/numeric%2Fmath%2Ffrexp.html
new file mode 100644
index 00000000..60c85cff
--- /dev/null
+++ b/devdocs/c/numeric%2Fmath%2Ffrexp.html
@@ -0,0 +1,79 @@
+ <h1 id="firstHeading" class="firstHeading">frexp, frexpf, frexpl</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 frexpf( 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"> <td> <pre data-language="c">double frexp( double arg, int* exp );</pre>
+</td> <td> (2) </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">long double frexpl( 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 frexp( arg, exp )</pre>
+</td> <td> (4) </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)</span> Decomposes given floating point value <code>x</code> into a normalized fraction and an integral power of two.</div> <div class="t-li1">
+<span class="t-li">4)</span> Type-generic macro: If <code>arg</code> has type <code>long double</code>, <code>frexpl</code> is called. Otherwise, if <code>arg</code> has integer type or the type <code>double</code>, <code>frexp</code> is called. Otherwise, <code>frexpf</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> pointer to integer value to store the exponent to </td>
+</tr>
+</table> <h3 id="Return_value"> Return value</h3> <p>If <code>arg</code> is zero, returns zero and stores zero in <code>*exp</code>.</p>
+<p>Otherwise (if <code>arg</code> is not zero), if no errors occur, returns the value <code>x</code> in the range <code>(-1;-0.5], [0.5; 1)</code> and stores an integer value in <code><span class="sy2">*</span><a href="http://en.cppreference.com/w/c/numeric/math/exp"><span class="kw657">exp</span></a></code> such that x×2<sup class="t-su">(*exp)</sup>=arg.</p>
+<p>If the value to be stored in <code>*exp</code> is outside the range of <code>int</code>, the behavior is unspecified.</p>
+<p>If <code>arg</code> is not a floating-point number, the behavior is unspecified.</p>
+<h3 id="Error_handling"> Error handling</h3> <p>This function is not subject to any errors specified in <a href="math_errhandling" title="c/numeric/math/math errhandling">math_errhandling</a>.</p>
+<p>If the implementation supports IEEE floating-point arithmetic (IEC 60559),</p>
+<ul>
+<li> If <code>arg</code> is ±0, it is returned, unmodified, and <code>0</code> is stored in <code><span class="sy2">*</span><a href="http://en.cppreference.com/w/c/numeric/math/exp"><span class="kw657">exp</span></a></code>. </li>
+<li> If <code>arg</code> is ±∞, it is returned, and an unspecified value is stored in <code><span class="sy2">*</span><a href="http://en.cppreference.com/w/c/numeric/math/exp"><span class="kw657">exp</span></a></code>. </li>
+<li> If <code>arg</code> is NaN, NaN is returned, and an unspecified value is stored in <code><span class="sy2">*</span><a href="http://en.cppreference.com/w/c/numeric/math/exp"><span class="kw657">exp</span></a></code>. </li>
+<li> No floating-point exceptions are raised. </li>
+<li> If <code><a href="../../types/limits" title="c/types/limits">FLT_RADIX</a></code> is 2 (or a power of 2), the returned value is exact, <a href="../fenv/fe_round" title="c/numeric/fenv/FE round">the current rounding mode</a> is ignored </li>
+</ul> <h3 id="Notes"> Notes</h3> <p>On a binary system (where <code><a href="../../types/limits" title="c/types/limits">FLT_RADIX</a></code> is <code>2</code>), <code>frexp</code> may be implemented as</p>
+<div class="c source-c"><pre data-language="c">{
+ *exp = (value == 0) ? 0 : (int)(1 + logb(value));
+ return scalbn(value, -(*exp));
+}</pre></div> <p>The function <code>frexp</code>, together with its dual, <code><a href="ldexp" title="c/numeric/math/ldexp">ldexp</a></code>, can be used to manipulate the representation of a floating-point number without direct bit manipulations.</p>
+<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;stdio.h&gt;
+#include &lt;math.h&gt;
+#include &lt;float.h&gt;
+
+int main(void)
+{
+ double f = 123.45;
+ printf("Given the number %.2f or %a in hex,\n", f, f);
+
+ double f3;
+ double f2 = modf(f, &amp;f3);
+ printf("modf() makes %.0f + %.2f\n", f3, f2);
+
+ int i;
+ f2 = frexp(f, &amp;i);
+ printf("frexp() makes %f * 2^%d\n", f2, i);
+
+ i = ilogb(f);
+ printf("logb()/ilogb() make %f * %d^%d\n", f/scalbn(1.0, i), FLT_RADIX, i);
+}</pre></div> <p>Possible output:</p>
+<div class="text source-text"><pre data-language="c">Given the number 123.45 or 0x1.edccccccccccdp+6 in hex,
+modf() makes 123 + 0.45
+frexp() makes 0.964453 * 2^7
+logb()/ilogb() make 1.92891 * 2^6</pre></div> </div> <h3 id="References"> References</h3> <ul>
+<li> C11 standard (ISO/IEC 9899:2011): </li>
+<ul>
+<li> 7.12.6.4 The frexp functions (p: 243) </li>
+<li> 7.25 Type-generic math &lt;tgmath.h&gt; (p: 373-375) </li>
+<li> F.10.3.4 The frexp functions (p: 521) </li>
+</ul>
+<li> C99 standard (ISO/IEC 9899:1999): </li>
+<ul>
+<li> 7.12.6.4 The frexp functions (p: 224) </li>
+<li> 7.22 Type-generic math &lt;tgmath.h&gt; (p: 335-337) </li>
+<li> F.9.3.4 The frexp functions (p: 458) </li>
+</ul>
+<li> C89/C90 standard (ISO/IEC 9899:1990): </li>
+<ul><li> 4.5.4.2 The frexp function </li></ul>
+</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <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> <div><a href="logb" title="c/numeric/math/logb"> <span class="t-lines"><span>logb</span><span>logbf</span><span>logbl</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><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> extracts exponent of the given number <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="ilogb" title="c/numeric/math/ilogb"> <span class="t-lines"><span>ilogb</span><span>ilogbf</span><span>ilogbl</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><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> extracts exponent of the given number <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="modf" title="c/numeric/math/modf"> <span class="t-lines"><span>modf</span><span>modff</span><span>modfl</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 integer and fractional parts <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/frexp" title="cpp/numeric/math/frexp">C++ documentation</a></span> for <code>frexp</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/frexp" class="_attribution-link">https://en.cppreference.com/w/c/numeric/math/frexp</a>
+ </p>
+</div>