summaryrefslogtreecommitdiff
path: root/devdocs/c/numeric%2Fmath%2Ffpclassify.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/c/numeric%2Fmath%2Ffpclassify.html')
-rw-r--r--devdocs/c/numeric%2Fmath%2Ffpclassify.html52
1 files changed, 52 insertions, 0 deletions
diff --git a/devdocs/c/numeric%2Fmath%2Ffpclassify.html b/devdocs/c/numeric%2Fmath%2Ffpclassify.html
new file mode 100644
index 00000000..0014938b
--- /dev/null
+++ b/devdocs/c/numeric%2Fmath%2Ffpclassify.html
@@ -0,0 +1,52 @@
+ <h1 id="firstHeading" class="firstHeading">fpclassify</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">#define fpclassify(arg) /* implementation defined */</pre>
+</td> <td class="t-dcl-nopad"> </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> </table> <p>Categorizes floating point value <code>arg</code> into the following categories: zero, subnormal, normal, infinite, NAN, or implementation-defined category. The macro returns an integral value.</p>
+<p><code><a href="../../types/limits/flt_eval_method" title="c/types/limits/FLT EVAL METHOD">FLT_EVAL_METHOD</a></code> is ignored: even if the argument is evaluated with more range and precision than its type, it is first converted to its semantic type, and the classification is based on that: a normal long double value might become subnormal when converted to double and zero when converted to float.</p>
+<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>One of <code><a href="fp_categories" title="c/numeric/math/FP categories">FP_INFINITE</a></code>, <code><a href="fp_categories" title="c/numeric/math/FP categories">FP_NAN</a></code>, <code><a href="fp_categories" title="c/numeric/math/FP categories">FP_NORMAL</a></code>, <code><a href="fp_categories" title="c/numeric/math/FP categories">FP_SUBNORMAL</a></code>, <code><a href="fp_categories" title="c/numeric/math/FP categories">FP_ZERO</a></code> or implementation-defined type, specifying the category of <code>arg</code>.</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;
+
+const char *show_classification(double x) {
+ switch(fpclassify(x)) {
+ case FP_INFINITE: return "Inf";
+ case FP_NAN: return "NaN";
+ case FP_NORMAL: return "normal";
+ case FP_SUBNORMAL: return "subnormal";
+ case FP_ZERO: return "zero";
+ default: return "unknown";
+ }
+}
+int main(void)
+{
+ printf("1.0/0.0 is %s\n", show_classification(1/0.0));
+ printf("0.0/0.0 is %s\n", show_classification(0.0/0.0));
+ printf("DBL_MIN/2 is %s\n", show_classification(DBL_MIN/2));
+ printf("-0.0 is %s\n", show_classification(-0.0));
+ printf("1.0 is %s\n", show_classification(1.0));
+}</pre></div> <p>Output:</p>
+<div class="text source-text"><pre data-language="c">1.0/0.0 is Inf
+0.0/0.0 is NaN
+DBL_MIN/2 is subnormal
+-0.0 is zero
+1.0 is normal</pre></div> </div> <h3 id="References"> References</h3> <ul>
+<li> C11 standard (ISO/IEC 9899:2011): </li>
+<ul><li> 7.12.3.1 The fpclassify macro (p: 235) </li></ul>
+<li> C99 standard (ISO/IEC 9899:1999): </li>
+<ul><li> 7.12.3.1 The fpclassify macro (p: 216) </li></ul>
+</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="isfinite" title="c/numeric/math/isfinite"> <span class="t-lines"><span>isfinite</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> checks if the given number has finite value <br> <span class="t-mark">(function macro)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="isinf" title="c/numeric/math/isinf"> <span class="t-lines"><span>isinf</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> checks if the given number is infinite <br> <span class="t-mark">(function macro)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="isnan" title="c/numeric/math/isnan"> <span class="t-lines"><span>isnan</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> checks if the given number is NaN <br> <span class="t-mark">(function macro)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="isnormal" title="c/numeric/math/isnormal"> <span class="t-lines"><span>isnormal</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> checks if the given number is normal <br> <span class="t-mark">(function macro)</span> </td>
+</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/numeric/math/fpclassify" title="cpp/numeric/math/fpclassify">C++ documentation</a></span> for <code>fpclassify</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/fpclassify" class="_attribution-link">https://en.cppreference.com/w/c/numeric/math/fpclassify</a>
+ </p>
+</div>