summaryrefslogtreecommitdiff
path: root/devdocs/c/numeric%2Fmath%2Fhuge_val.html
blob: d95e528ba738f0a8a86b5afa9eda0bfb66528738 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
    <h1 id="firstHeading" class="firstHeading">HUGE_VALF, HUGE_VAL, HUGE_VALL</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 HUGE_VALF /*implementation defined*/</pre>
</td> <td class="t-dcl-nopad"> </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl"> <td class="t-dcl-nopad"> <pre data-language="c">#define HUGE_VAL  /*implementation defined*/</pre>
</td> <td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">#define HUGE_VALL /*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>The <code>HUGE_VALF</code>, <code>HUGE_VAL</code> and <code>HUGE_VALL</code> macros expand to positive floating point constant expressions which compare equal to the values returned by floating-point functions and operators in case of overflow (see <a href="math_errhandling" title="c/numeric/math/math errhandling"><code>math_errhandling</code></a>).</p>
<table class="t-dsc-begin"> <tr class="t-dsc-hitem"> <th> Constant </th> <th> Explanation </th>
</tr> <tr class="t-dsc"> <td> <code>HUGE_VALF</code> </td> <td> Expands to positive <code>float</code> expression that indicates overflow </td>
</tr> <tr class="t-dsc"> <td> <code>HUGE_VAL</code> </td> <td> Expands to positive <code>double</code> expression that indicates overflow, not necessarily representable as a <code>float</code> </td>
</tr> <tr class="t-dsc"> <td> <code>HUGE_VALL</code> </td> <td> Expands to positive <code>long double</code> expression that indicates overflow, not necessarily representable as a <code>float</code> or <code>double</code> </td>
</tr> </table> <p>On implementations that support floating-point infinities, these macros always expand to the positive infinities of <code>float</code>, <code>double</code>, and <code>long double</code>, respectively.</p>
<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;math.h&gt;
#include &lt;stdio.h&gt;
 
int main(void)
{
    const double result = 1.0 / 0.0;
    printf("1.0/0.0 == %f\n", result);
    if (result == HUGE_VAL)
        puts("1.0/0.0 == HUGE_VAL");
}</pre></div> <p>Possible output:</p>
<div class="text source-text"><pre data-language="c">1.0/0.0 == inf
1.0/0.0 == HUGE_VAL</pre></div> </div> <h3 id="References"> References</h3>  <ul>
<li> C23 standard (ISO/IEC 9899:2023): </li>
<ul>
<li> 7.12/3 HUGE_VAL, HUGE_VALF, HUGE_VALL (p: TBD) </li>
<li> F.10/2 HUGE_VAL, HUGE_VALF, HUGE_VALL (p: TBD) </li>
</ul>
<li> C17 standard (ISO/IEC 9899:2018): </li>
<ul>
<li> 7.12/3 HUGE_VAL, HUGE_VALF, HUGE_VALL (p: TBD) </li>
<li> F.10/2 HUGE_VAL, HUGE_VALF, HUGE_VALL (p: TBD) </li>
</ul>
<li> C11 standard (ISO/IEC 9899:2011): </li>
<ul>
<li> 7.12/3 HUGE_VAL, HUGE_VALF, HUGE_VALL (p: 231) </li>
<li> F.10/2 HUGE_VAL, HUGE_VALF, HUGE_VALL (p: 517) </li>
</ul>
<li> C99 standard (ISO/IEC 9899:1999): </li>
<ul>
<li> 7.12/3 HUGE_VAL, HUGE_VALF, HUGE_VALL (p: 212) </li>
<li> F.9/2 HUGE_VAL, HUGE_VALF, HUGE_VALL (p: 454) </li>
</ul>
<li> C89/C90 standard (ISO/IEC 9899:1990): </li>
<ul><li> 4.5 HUGE_VAL </li></ul>
</ul>                       <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="infinity" title="c/numeric/math/INFINITY"> <span class="t-lines"><span>INFINITY</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> evaluates to positive infinity or the value guaranteed to overflow a <code>float</code> <br> <span class="t-mark">(macro constant)</span>  </td>
</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/numeric/math/HUGE_VAL" title="cpp/numeric/math/HUGE VAL">C++ documentation</a></span> for <code>HUGE_VAL</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/HUGE_VAL" class="_attribution-link">https://en.cppreference.com/w/c/numeric/math/HUGE_VAL</a>
  </p>
</div>