summaryrefslogtreecommitdiff
path: root/devdocs/c/numeric%2Fmath%2Fcbrt.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/c/numeric%2Fmath%2Fcbrt.html')
-rw-r--r--devdocs/c/numeric%2Fmath%2Fcbrt.html71
1 files changed, 71 insertions, 0 deletions
diff --git a/devdocs/c/numeric%2Fmath%2Fcbrt.html b/devdocs/c/numeric%2Fmath%2Fcbrt.html
new file mode 100644
index 00000000..bb548272
--- /dev/null
+++ b/devdocs/c/numeric%2Fmath%2Fcbrt.html
@@ -0,0 +1,71 @@
+ <h1 id="firstHeading" class="firstHeading">cbrt, cbrtf, cbrtl</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 cbrtf( float arg );</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 cbrt( double arg );</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 cbrtl( long double arg );</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 cbrt( arg )</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> Computes the cube root of <code>arg</code>.</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>cbrtl</code> is called. Otherwise, if <code>arg</code> has integer type or the type <code>double</code>, <code>cbrt</code> is called. Otherwise, <code>cbrtf</code> is called.</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>
+</table> <h3 id="Return_value"> Return value</h3> <p>If no errors occur, the cube root of <code>arg</code> (\(\small{\sqrt[3]{arg} }\)<span class="t-mrad"><span>3</span><span>√</span><span>arg</span></span>), is returned.</p>
+<p>If a range error occurs due to underflow, 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> if the argument is ±0 or ±∞, it is returned, unchanged </li>
+<li> if the argument is NaN, NaN is returned. </li>
+</ul> <h3 id="Notes"> Notes</h3> <code>cbrt(arg)</code> is not equivalent to <code><a href="http://en.cppreference.com/w/c/numeric/math/pow"><span class="kw667">pow</span></a><span class="br0">(</span>arg, <span class="nu16">1.0</span><span class="sy2">/</span><span class="nu0">3</span><span class="br0">)</span></code> because the rational number \(\small{\frac1{3} }\)<span><span>1</span><span>/</span><span>3</span></span> is typically not equal to <code>1.0/3</code> and <code>std::pow</code> cannot raise a negative base to a fractional exponent. Moreover, <code>cbrt(arg)</code> usually gives more accurate results than <code><a href="http://en.cppreference.com/w/c/numeric/math/pow"><span class="kw667">pow</span></a><span class="br0">(</span>arg, <span class="nu16">1.0</span><span class="sy2">/</span><span class="nu0">3</span><span class="br0">)</span></code> (see example). <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;float.h&gt;
+#include &lt;math.h&gt;
+
+int main(void)
+{
+ printf("Normal use:\n"
+ "cbrt(729) = %f\n", cbrt(729));
+ printf("cbrt(-0.125) = %f\n", cbrt(-0.125));
+ printf("Special values:\n"
+ "cbrt(-0) = %f\n", cbrt(-0.0));
+ printf("cbrt(+inf) = %f\n", cbrt(INFINITY));
+ printf("Accuracy:\n"
+ "cbrt(343) = %.*f\n", DBL_DECIMAL_DIG, cbrt(343));
+ printf("pow(343,1.0/3) = %.*f\n", DBL_DECIMAL_DIG, pow(343, 1.0/3));
+}</pre></div> <p>Possible output:</p>
+<div class="text source-text"><pre data-language="c">Normal use:
+cbrt(729) = 9.000000
+cbrt(-0.125) = -0.500000
+Special values:
+cbrt(-0) = -0.000000
+cbrt(+inf) = inf
+Accuracy:
+cbrt(343) = 7.00000000000000000
+pow(343,1.0/3) = 6.99999999999999911</pre></div> </div> <h3 id="References"> References</h3> <ul>
+<li> C17 standard (ISO/IEC 9899:2018): </li>
+<ul>
+<li> 7.12.7.1 The cbrt functions (p: 180-181) </li>
+<li> 7.25 Type-generic math &lt;tgmath.h&gt; (p: 272-273) </li>
+<li> F.10.4.1 The cbrt functions (p: 381-) </li>
+</ul>
+<li> C11 standard (ISO/IEC 9899:2011): </li>
+<ul>
+<li> 7.12.7.1 The cbrt functions (p: 247) </li>
+<li> 7.25 Type-generic math &lt;tgmath.h&gt; (p: 373-375) </li>
+<li> F.10.4.1 The cbrt functions (p: 524) </li>
+</ul>
+<li> C99 standard (ISO/IEC 9899:1999): </li>
+<ul>
+<li> 7.12.7.1 The cbrt functions (p: 228) </li>
+<li> 7.22 Type-generic math &lt;tgmath.h&gt; (p: 335-337) </li>
+<li> F.9.4.1 The cbrt 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="pow" title="c/numeric/math/pow"> <span class="t-lines"><span>pow</span><span>powf</span><span>powl</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> computes a number raised to the given power (\(\small{x^y}\)x<sup>y</sup>) <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="sqrt" title="c/numeric/math/sqrt"> <span class="t-lines"><span>sqrt</span><span>sqrtf</span><span>sqrtl</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> computes square root (\(\small{\sqrt{x} }\)<span class="t-mrad"><span>√</span><span>x</span></span>) <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="hypot" title="c/numeric/math/hypot"> <span class="t-lines"><span>hypot</span><span>hypotf</span><span>hypotl</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> computes square root of the sum of the squares of two given numbers (\(\scriptsize{\sqrt{x^2+y^2} }\)<span class="t-mrad"><span>√</span><span>x<sup class="t-su">2</sup>+y<sup class="t-su">2</sup></span></span>) <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/cbrt" title="cpp/numeric/math/cbrt">C++ documentation</a></span> for <code>cbrt</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/cbrt" class="_attribution-link">https://en.cppreference.com/w/c/numeric/math/cbrt</a>
+ </p>
+</div>