diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/c/types%2Flimits.html | |
new repository
Diffstat (limited to 'devdocs/c/types%2Flimits.html')
| -rw-r--r-- | devdocs/c/types%2Flimits.html | 218 |
1 files changed, 218 insertions, 0 deletions
diff --git a/devdocs/c/types%2Flimits.html b/devdocs/c/types%2Flimits.html new file mode 100644 index 00000000..ea79ff4c --- /dev/null +++ b/devdocs/c/types%2Flimits.html @@ -0,0 +1,218 @@ + <h1 id="firstHeading" class="firstHeading">Numeric limits</h1> <h3 id="Limits_of_integer_types"> Limits of integer types</h3> <table class="t-dsc-begin"> <tr> <td colspan="2"> <h5 id="Limits_of_core_language_integer_types"> Limits of core language integer types </h5> </td> +</tr> <tr class="t-dsc-header"> <th colspan="2"> Defined in header <code><limits.h></code> </th> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>BOOL_WIDTH</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c23">(C23)</span></span></span></div> </td> <td> bit width of _Bool <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>CHAR_BIT</span></span></div> </td> <td> number of bits in a byte <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>MB_LEN_MAX</span></span></div> </td> <td> maximum number of bytes in a multibyte character <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>CHAR_WIDTH</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c23">(C23)</span></span></span></div> </td> <td> bit width of <span class="kw4">char</span>, same as <code>CHAR_BIT</code> <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>CHAR_MIN</span></span></div> </td> <td> minimum value of <span class="kw4">char</span> <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>CHAR_MAX</span></span></div> </td> <td> maximum value of <span class="kw4">char</span> <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>SCHAR_WIDTH</span><span>SHRT_WIDTH</span><span>INT_WIDTH</span><span>LONG_WIDTH</span><span>LLONG_WIDTH</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c23">(C23)</span></span><span><span class="t-mark-rev t-since-c23">(C23)</span></span><span><span class="t-mark-rev t-since-c23">(C23)</span></span><span><span class="t-mark-rev t-since-c23">(C23)</span></span><span><span class="t-mark-rev t-since-c23">(C23)</span></span></span></div> </td> <td> bit width of <span class="kw4">signed</span> <span class="kw4">char</span>, <span class="kw4">short</span>, <span class="kw4">int</span>, <span class="kw4">long</span>, and <span class="kw4">long</span> <span class="kw4">long</span> respectively <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>SCHAR_MIN</span><span>SHRT_MIN</span><span>INT_MIN</span><span>LONG_MIN</span><span>LLONG_MIN</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> minimum value of <span class="kw4">signed</span> <span class="kw4">char</span>, <span class="kw4">short</span>, <span class="kw4">int</span>, <span class="kw4">long</span> and <span class="kw4">long</span> <span class="kw4">long</span> respectively <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>SCHAR_MAX</span><span>SHRT_MAX</span><span>INT_MAX</span><span>LONG_MAX</span><span>LLONG_MAX</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> maximum value of <span class="kw4">signed</span> <span class="kw4">char</span>, <span class="kw4">short</span>, <span class="kw4">int</span>, <span class="kw4">long</span> and <span class="kw4">long</span> <span class="kw4">long</span> respectively <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>UCHAR_WIDTH</span><span>USHRT_WIDTH</span><span>UINT_WIDTH</span><span>ULONG_WIDTH</span><span>ULLONG_WIDTH</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c23">(C23)</span></span><span><span class="t-mark-rev t-since-c23">(C23)</span></span><span><span class="t-mark-rev t-since-c23">(C23)</span></span><span><span class="t-mark-rev t-since-c23">(C23)</span></span><span><span class="t-mark-rev t-since-c23">(C23)</span></span></span></div> </td> <td> bit width of <span class="kw4">unsigned</span> <span class="kw4">char</span>, <span class="kw4">unsigned</span> <span class="kw4">short</span>, <span class="kw4">unsigned</span> <span class="kw4">int</span>, <span class="kw4">unsigned</span> <span class="kw4">long</span>, and <span class="kw4">unsigned</span> <span class="kw4">long</span> <span class="kw4">long</span> respectively <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>UCHAR_MAX</span><span>USHRT_MAX</span><span>UINT_MAX</span><span>ULONG_MAX</span><span>ULLONG_MAX</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> maximum value of <span class="kw4">unsigned</span> <span class="kw4">char</span>, <span class="kw4">unsigned</span> <span class="kw4">short</span>, <span class="kw4">unsigned</span> <span class="kw4">int</span>,<br><span class="kw4">unsigned</span> <span class="kw4">long</span> and <span class="kw4">unsigned</span> <span class="kw4">long</span> <span class="kw4">long</span> respectively <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>BITINT_MAXWIDTH</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c23">(C23)</span></span></span></div> </td> <td> maximum width N supported by the declaration of a bit-precise integer in the type specifier _BitInt<span class="br0">(</span>N<span class="br0">)</span>, greater than or equal to <code>ULLONG_WIDTH</code> <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr> <td colspan="2"> <h5 id="Limits_of_library_type_aliases"> Limits of library type aliases </h5> </td> +</tr> <tr class="t-dsc-header"> <th colspan="2"> Defined in header <code><stdint.h></code> </th> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>PTRDIFF_WIDTH</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c23">(C23)</span></span></span></div> </td> <td> bit width of object of <code><a href="ptrdiff_t" title="c/types/ptrdiff t">ptrdiff_t</a></code> type <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>PTRDIFF_MIN</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> minimum value of <code><a href="ptrdiff_t" title="c/types/ptrdiff t">ptrdiff_t</a></code> <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>PTRDIFF_MAX</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> maximum value of <code><a href="ptrdiff_t" title="c/types/ptrdiff t">ptrdiff_t</a></code> <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>SIZE_WIDTH</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c23">(C23)</span></span></span></div> </td> <td> bit width of object of <code><a href="size_t" title="c/types/size t">size_t</a></code> type <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>SIZE_MAX</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> maximum value of <code><a href="size_t" title="c/types/size t">size_t</a></code> <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>SIG_ATOMIC_WIDTH</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c23">(C23)</span></span></span></div> </td> <td> bit width of object of <code><a href="../program/sig_atomic_t" title="c/program/sig atomic t">sig_atomic_t</a></code> type <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>SIG_ATOMIC_MIN</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> minimum value of <code><a href="../program/sig_atomic_t" title="c/program/sig atomic t">sig_atomic_t</a></code> <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>SIG_ATOMIC_MAX</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> maximum value of <code><a href="../program/sig_atomic_t" title="c/program/sig atomic t">sig_atomic_t</a></code> <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>WINT_WIDTH</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c23">(C23)</span></span></span></div> </td> <td> bit width of object of wint_t type <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>WINT_MIN</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> minimum value of <code>wint_t</code> <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>WINT_MAX</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> maximum value of <code>wint_t</code> <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc-header"> <th colspan="2"> Defined in header <code><wchar.h></code> </th> +</tr> <tr class="t-dsc-header"> <th colspan="2"> Defined in header <code><stdint.h></code> </th> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>WCHAR_WIDTH</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c23">(C23)</span></span></span></div> </td> <td> bit width of object of <span class="kw4">wchar_t</span> type <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>WCHAR_MIN</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> minimum value of <span class="kw4">wchar_t</span> <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>WCHAR_MAX</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> maximum value of <span class="kw4">wchar_t</span> <br> <span class="t-mark">(macro constant)</span> </td> +</tr> </table> <h4 id="Notes"> Notes</h4> <p>The types of these constants, other than <code>CHAR_BIT</code> and <code>MB_LEN_MAX</code>, are required to match the results of the <a href="../language/conversion#Integer_promotions" title="c/language/conversion">integral promotions</a> as applied to objects of the types they describe: <code>CHAR_MAX</code> may have type <span class="kw4">int</span> or <span class="kw4">unsigned</span> <span class="kw4">int</span>, but never <span class="kw4">char</span>. Similarly <code>USHRT_MAX</code> may not be of an unsigned type: its type may be <span class="kw4">int</span>.</p> +<p>A freestanding implementation may lack <code><a href="../program/sig_atomic_t" title="c/program/sig atomic t">sig_atomic_t</a></code> and/or wint_t typedef names, in which case the <code>SIG_ATOMIC_*</code> and/or <code>WINT_*</code> macros are correspondingly absent.</p> +<h4 id="Example"> Example</h4> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include <limits.h> +#include <stdint.h> +#include <stdio.h> + +int main(void) +{ + printf("CHAR_BIT = %d\n", CHAR_BIT); + printf("MB_LEN_MAX = %d\n\n", MB_LEN_MAX); + + printf("CHAR_MIN = %+d\n", CHAR_MIN); + printf("CHAR_MAX = %+d\n", CHAR_MAX); + printf("SCHAR_MIN = %+d\n", SCHAR_MIN); + printf("SCHAR_MAX = %+d\n", SCHAR_MAX); + printf("UCHAR_MAX = %u\n\n", UCHAR_MAX); + + printf("SHRT_MIN = %+d\n", SHRT_MIN); + printf("SHRT_MAX = %+d\n", SHRT_MAX); + printf("USHRT_MAX = %u\n\n", USHRT_MAX); + + printf("INT_MIN = %+d\n", INT_MIN); + printf("INT_MAX = %+d\n", INT_MAX); + printf("UINT_MAX = %u\n\n", UINT_MAX); + + printf("LONG_MIN = %+ld\n", LONG_MIN); + printf("LONG_MAX = %+ld\n", LONG_MAX); + printf("ULONG_MAX = %lu\n\n", ULONG_MAX); + + printf("LLONG_MIN = %+lld\n", LLONG_MIN); + printf("LLONG_MAX = %+lld\n", LLONG_MAX); + printf("ULLONG_MAX = %llu\n\n", ULLONG_MAX); + + printf("PTRDIFF_MIN = %td\n", PTRDIFF_MIN); + printf("PTRDIFF_MAX = %+td\n", PTRDIFF_MAX); + printf("SIZE_MAX = %zu\n", SIZE_MAX); + printf("SIG_ATOMIC_MIN = %+jd\n",(intmax_t)SIG_ATOMIC_MIN); + printf("SIG_ATOMIC_MAX = %+jd\n",(intmax_t)SIG_ATOMIC_MAX); + printf("WCHAR_MIN = %+jd\n",(intmax_t)WCHAR_MIN); + printf("WCHAR_MAX = %+jd\n",(intmax_t)WCHAR_MAX); + printf("WINT_MIN = %jd\n", (intmax_t)WINT_MIN); + printf("WINT_MAX = %jd\n", (intmax_t)WINT_MAX); +}</pre></div> <p>Possible output:</p> +<div class="text source-text"><pre data-language="c">CHAR_BIT = 8 +MB_LEN_MAX = 16 + +CHAR_MIN = -128 +CHAR_MAX = +127 +SCHAR_MIN = -128 +SCHAR_MAX = +127 +UCHAR_MAX = 255 + +SHRT_MIN = -32768 +SHRT_MAX = +32767 +USHRT_MAX = 65535 + +INT_MIN = -2147483648 +INT_MAX = +2147483647 +UINT_MAX = 4294967295 + +LONG_MIN = -9223372036854775808 +LONG_MAX = +9223372036854775807 +ULONG_MAX = 18446744073709551615 + +LLONG_MIN = -9223372036854775808 +LLONG_MAX = +9223372036854775807 +ULLONG_MAX = 18446744073709551615 + +PTRDIFF_MIN = -9223372036854775808 +PTRDIFF_MAX = +9223372036854775807 +SIZE_MAX = 18446744073709551615 +SIG_ATOMIC_MIN = -2147483648 +SIG_ATOMIC_MAX = +2147483647 +WCHAR_MIN = -2147483648 +WCHAR_MAX = +2147483647 +WINT_MIN = 0 +WINT_MAX = 4294967295</pre></div> </div> <h3 id="Limits_of_floating-point_types"> Limits of floating-point types</h3> <table class="t-dsc-begin"> <tr class="t-dsc-header"> <th colspan="2"> Defined in header <code><float.h></code> </th> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>FLT_RADIX</span></span></div> </td> <td> the radix (integer base) used by the representation of all three floating-point types <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>DECIMAL_DIG</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> conversion from <span class="kw4">long</span> <span class="kw4">double</span> to decimal with at least <code>DECIMAL_DIG</code> digits and back to <span class="kw4">long</span> <span class="kw4">double</span> is the identity conversion: this is the decimal precision required to serialize/deserialize a <span class="kw4">long</span> <span class="kw4">double</span> <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>FLT_DECIMAL_DIG</span><span>DBL_DECIMAL_DIG</span><span>LDBL_DECIMAL_DIG</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> conversion from <span class="kw4">float</span>/<span class="kw4">double</span>/<span class="kw4">long</span> <span class="kw4">double</span> to decimal with at least <code>FLT_DECIMAL_DIG</code>/<code>DBL_DECIMAL_DIG</code>/<code>LDBL_DECIMAL_DIG</code> digits and back is the identity conversion: this is the decimal precision required to serialize/deserialize a floating-point value. Defined to at least <code>6</code>, <code>10</code>, and <code>10</code> respectively, or <code>9</code> for IEEE float and <code>17</code> for IEEE double (see also the C++ analog: <a href="https://en.cppreference.com/w/cpp/types/numeric_limits/max_digits10" title="cpp/types/numeric limits/max digits10"><code>max_digits10</code></a>) <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>FLT_MIN</span><span>DBL_MIN</span><span>LDBL_MIN</span></span></div> </td> <td> minimum, normalized, positive value of <span class="kw4">float</span>, <span class="kw4">double</span> and <span class="kw4">long</span> <span class="kw4">double</span> respectively <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>FLT_TRUE_MIN</span><span>DBL_TRUE_MIN</span><span>LDBL_TRUE_MIN</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> minimum positive value of <span class="kw4">float</span>, <span class="kw4">double</span> and <span class="kw4">long</span> <span class="kw4">double</span> respectively <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>FLT_MAX</span><span>DBL_MAX</span><span>LDBL_MAX</span></span></div> </td> <td> maximum finite value of <span class="kw4">float</span>, <span class="kw4">double</span> and <span class="kw4">long</span> <span class="kw4">double</span> respectively <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>FLT_EPSILON</span><span>DBL_EPSILON</span><span>LDBL_EPSILON</span></span></div> </td> <td> absolute value difference between <code>1.0</code> and the next representable value for <span class="kw4">float</span>, <span class="kw4">double</span> and <span class="kw4">long</span> <span class="kw4">double</span> respectively <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>FLT_DIG</span><span>DBL_DIG</span><span>LDBL_DIG</span></span></div> </td> <td> number of decimal digits that are guaranteed to be preserved in text → <span class="kw4">float</span>/<span class="kw4">double</span>/<span class="kw4">long</span> <span class="kw4">double</span> → text roundtrip without change due to rounding or overflow (see the C++ analog <a href="https://en.cppreference.com/w/cpp/types/numeric_limits/digits10" title="cpp/types/numeric limits/digits10"><code>digits10</code></a> for detail) <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>FLT_MANT_DIG</span><span>DBL_MANT_DIG</span><span>LDBL_MANT_DIG</span></span></div> </td> <td> number of base-<code>FLT_RADIX</code> digits that are in the floating-point mantissa and that can be represented without losing precision for <span class="kw4">float</span>, <span class="kw4">double</span> and <span class="kw4">long</span> <span class="kw4">double</span> respectively <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>FLT_MIN_EXP</span><span>DBL_MIN_EXP</span><span>LDBL_MIN_EXP</span></span></div> </td> <td> minimum negative integer such that <code>FLT_RADIX</code> raised by power one less than that integer is a normalized <span class="kw4">float</span>, <span class="kw4">double</span> and <span class="kw4">long</span> <span class="kw4">double</span> respectively <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>FLT_MIN_10_EXP</span><span>DBL_MIN_10_EXP</span><span>LDBL_MIN_10_EXP</span></span></div> </td> <td> minimum negative integer such that 10 raised by power one less than that integer is a normalized <span class="kw4">float</span>, <span class="kw4">double</span> and <span class="kw4">long</span> <span class="kw4">double</span> respectively <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>FLT_MAX_EXP</span><span>DBL_MAX_EXP</span><span>LDBL_MAX_EXP</span></span></div> </td> <td> maximum positive integer such that <code>FLT_RADIX</code> raised by power one less than that integer is a representable finite <span class="kw4">float</span>, <span class="kw4">double</span> and <span class="kw4">long</span> <span class="kw4">double</span> respectively <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>FLT_MAX_10_EXP</span><span>DBL_MAX_10_EXP</span><span>LDBL_MAX_10_EXP</span></span></div> </td> <td> maximum positive integer such that 10 raised by power one less than that integer is a representable finite <span class="kw4">float</span>, <span class="kw4">double</span> and <span class="kw4">long</span> <span class="kw4">double</span> respectively <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><a href="limits/flt_rounds" title="c/types/limits/FLT ROUNDS"> <span class="t-lines"><span>FLT_ROUNDS</span></span></a></div> </td> <td> rounding mode of floating-point arithmetic <br> <span class="t-mark">(macro constant)</span> </td> +</tr> <tr class="t-dsc"> <td> <div><a href="limits/flt_eval_method" title="c/types/limits/FLT EVAL METHOD"> <span class="t-lines"><span>FLT_EVAL_METHOD</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> use of extended precision for intermediate results:<br> <code>0</code> – not used, <code>1</code> – <span class="kw4">double</span> is used instead of <span class="kw4">float</span>, <code>2</code> – <span class="kw4">long</span> <span class="kw4">double</span> is used <br> <span class="t-mark">(macro constant)</span> </td> +</tr> </table> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><span class="t-lines"><span>FLT_HAS_SUBNORM</span><span>DBL_HAS_SUBNORM</span><span>LDBL_HAS_SUBNORM</span></span></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c11">(C11)</span><span class="t-mark-rev t-deprecated-c23">(deprecated in C23)</span></span></span></div> </td> <td> whether the type supports subnormal (<a href="https://en.wikipedia.org/wiki/Denormal_number" class="extiw" title="enwiki:Denormal number">denormal</a>) numbers:<br><code>-1</code> – indeterminable, <code>0</code> – absent, <code>1</code> – present <br> <span class="t-mark">(macro constant)</span> </td> +</tr> </table> <h4 id="Example_2"> Example</h4> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include <float.h> +#include <math.h> +#include <stdio.h> + +int main(void) +{ + printf("DECIMAL_DIG = %d\n", DECIMAL_DIG); + printf("FLT_DECIMAL_DIG = %d\n", FLT_DECIMAL_DIG); + printf("FLT_RADIX = %d\n", FLT_RADIX); + printf("FLT_MIN = %e\n", FLT_MIN); + printf("FLT_MAX = %e\n", FLT_MAX); + printf("FLT_EPSILON = %e\n", FLT_EPSILON); + printf("FLT_DIG = %d\n", FLT_DIG); + printf("FLT_MANT_DIG = %d\n", FLT_MANT_DIG); + printf("FLT_MIN_EXP = %d\n", FLT_MIN_EXP); + printf("FLT_MIN_10_EXP = %d\n", FLT_MIN_10_EXP); + printf("FLT_MAX_EXP = %d\n", FLT_MAX_EXP); + printf("FLT_MAX_10_EXP = %d\n", FLT_MAX_10_EXP); + printf("FLT_ROUNDS = %d\n", FLT_ROUNDS); + printf("FLT_EVAL_METHOD = %d\n", FLT_EVAL_METHOD); + printf("FLT_HAS_SUBNORM = %d\n", FLT_HAS_SUBNORM); +}</pre></div> <p>Possible output:</p> +<div class="text source-text"><pre data-language="c">DECIMAL_DIG = 37 +FLT_DECIMAL_DIG = 9 +FLT_RADIX = 2 +FLT_MIN = 1.175494e-38 +FLT_MAX = 3.402823e+38 +FLT_EPSILON = 1.192093e-07 +FLT_DIG = 6 +FLT_MANT_DIG = 24 +FLT_MIN_EXP = -125 +FLT_MIN_10_EXP = -37 +FLT_MAX_EXP = 128 +FLT_MAX_10_EXP = 38 +FLT_ROUNDS = 1 +FLT_EVAL_METHOD = 1 +FLT_HAS_SUBNORM = 1</pre></div> </div> <h3 id="References"> References</h3> <ul> +<li> C23 standard (ISO/IEC 9899:2023): </li> +<ul> +<li> 5.2.4.2 Numerical limits (p: TBD) </li> +<li> 7.22.3 Limits of other integer types (p: TBD) </li> +</ul> +<li> C17 standard (ISO/IEC 9899:2018): </li> +<ul> +<li> 5.2.4.2 Numerical limits (p: 20-27) </li> +<li> 7.20.3 Limits of other integer types (p: 215-216) </li> +</ul> +<li> C11 standard (ISO/IEC 9899:2011): </li> +<ul> +<li> 5.2.4.2 Numerical limits (p: 26-34) </li> +<li> 7.20.3 Limits of other integer types (p: 293-294) </li> +</ul> +<li> C99 standard (ISO/IEC 9899:1999): </li> +<ul> +<li> 5.2.4.2 Numerical limits (p: 21-28) </li> +<li> 7.18.3 Limits of other integer types (p: 259-260) </li> +</ul> +<li> C89/C90 standard (ISO/IEC 9899:1990): </li> +<ul><li> 2.2.4.2 Numerical limits </li></ul> +</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/types/climits" title="cpp/types/climits">C++ documentation</a></span> for <span class=""><span>C numeric limits interface</span></span> </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/types/limits" class="_attribution-link">https://en.cppreference.com/w/c/types/limits</a> + </p> +</div> |
