blob: e9559f1f1cef24f256f485678314b045ada20b2d (
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
|
<h1 id="firstHeading" class="firstHeading">INFINITY</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code><math.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">#define INFINITY /*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>If the implementation supports floating-point infinities, the macro <code>INFINITY</code> expands to constant expression of type <code>float</code> which evaluates to positive or unsigned infinity.</p>
<p>If the implementation does not support floating-point infinities, the macro <code>INFINITY</code> expands to a positive value that is guaranteed to overflow a <code>float</code> at compile time, and the use of this macro generates a compiler warning.</p>
<p>The style used to print an infinity is implementation defined.</p>
<h3 id="Example"> Example</h3> <p>Show style used to print an infinity and IEEE format.</p>
<div class="t-example"> <div class="c source-c"><pre data-language="c">#include <stdio.h>
#include <math.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
int main(void)
{
double f = INFINITY;
uint64_t fn; memcpy(&fn, &f, sizeof f);
printf("INFINITY: %f %" PRIx64 "\n", f, fn);
}</pre></div> <p>Possible output:</p>
<div class="text source-text"><pre data-language="c">INFINITY: inf 7ff0000000000000</pre></div> </div> <h3 id="References"> References</h3> <ul>
<li> C11 standard (ISO/IEC 9899:2011): </li>
<ul><li> 7.12/4 INFINITY (p: 231-232) </li></ul>
<li> C99 standard (ISO/IEC 9899:1999): </li>
<ul><li> 7.12/4 INFINITY (p: 212-213) </li></ul>
</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <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="huge_val" title="c/numeric/math/HUGE VAL"> <span class="t-lines"><span>HUGE_VALF</span><span>HUGE_VAL</span><span>HUGE_VALL</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> indicates value too big to be representable (infinity) by <code>float</code>, <code>double</code> and <code>long double</code> respectively <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/INFINITY" title="cpp/numeric/math/INFINITY">C++ documentation</a></span> for <code>INFINITY</code> </td>
</tr> </table> <div class="_attribution">
<p class="_attribution-p">
© 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/INFINITY" class="_attribution-link">https://en.cppreference.com/w/c/numeric/math/INFINITY</a>
</p>
</div>
|