Jens Gustedt

Ease the definition of extended integer types

Keywords: uintptr_t. These types counterpart phases, uintmax_t, preprocessing preprocessing preprocessing

The specifications of types [u]intmax_t and extended integer types lack to provide the extensibility feature for which they are designed. As a consequence existing "64 bit" implementations are not able to add standard conforming interfaces to their 128 bit or 256 bit integer types without breaking ABI compatibility.

Changelog:

-Changes from v.1, n2303:

-A detailed list of the types that are covered by [u]intmax_t is added to the normative text.

-A new pair of types is added that also captures extended integer types and that can be used for printf and similar, but that should not be part of any API or ABI. -The co-existence of "least" and "fast" signed and unsigned pairs of is enforced.

-Range inclusion of "least" and "fast" types with width N < M is enforced.

-Introduce type-generic macros int_abs, int_div, int_max, and int_min, intended to replace and complement imaxabs and imaxdiv functions. -Substitute integer-power functions compoundn, pown and rootn by type-generic macros of the same name that avoid the use of the [u]intmax_t types. -Substitute integer-power functions fromfp and similar by type-generic macros toint, touint, tointx and touintx that avoid the use of the [u]intmax_t types. -A previous version of this proposal has been discussed in message SC22WG14.15569 and the depending thread on the WG14 reflector.

The interaction between the definition of extended integer types and [u]intmax_t has resulted in a lack of extensibility for existing ABI. Platforms that fixed their specifications for the basic integer types and for [u]intmax_t cannot add an extended integer type that is wider than their current [u]intmax_t to their specification. As the current text of the C standard stands, such an addition would force a redefintion of [u]intmax_t to the wider types. This would have the following consequences:

-The parts of the C library that use [u]intmax_t (specific functions but also printf and friends) must be rewritten or recompiled with the new ABI and become binary incompatible with existing programs. -Programs compiled with the new ABI would be binary incompatible on platforms that have not been upgraded. -The preprocessor of the implementation must be re-engineered to comply to the standard.

In particular, there would occur severe specification problems for preprocessor numbers and their evaluation. E.g the value of ULLONG_MAX+1 is not expressible as a literal in the language proper but would be for the preprocessor. The expression ULLONG_MAX+1 would evaluate to true in a preprocessor conditional but to 0 (false) in later compilation phases.

As a consequence of these difficulties the concept of "extended integer type" is merely unused by implementations. I have not heard of any implementation that uses this concept. So as it stands this idea of "extended integer type" is basically a failure, nobody uses it, and intmax_t is usually just long or long long. This has lead to a sensible backlog for platforms such as gcc or clang that provide emulated 128 bit integer types (__[u]int128_t) on 64 bit platforms. They are not able to provide them as "extended integer types" in the sense of the C standard. More and more processor platforms even provide rudimentary support of 128 or 256 bit integers in hardware (e.g Intel's AVX vector unit), so it would really be productive to give more slack to implementations to integrate these types into existing ABI. Generally, we should not block implementations that are able to provide exact-width integer types for N > 64. These types can for example be used efficiently for bitsets, UUIDs, cryptography, checksums or networking (ipv6). They have well-defined standard interfaces in the form of ([u]intN _t) with easy to use feature tests.

SUGGESTED CHANGES

Changes directly concerning [u]intmax_t

I suggest to change the specification of [u]intmax_t such that they are only at least as wide as any integer type used by the standard. Thereby the greatest-width types do not have to cover all integer types, in particular not extended integer types that might be added later to an ABI. The change to the standard can be isolated in 7.20.1.15. The two main changes would be changing p1 and add a recommended practice section:

7.20.1.5 Greatest-width integer types :::

The :::::: types :::::::: intmax_t :::: and :::::::::: uintmax_t :::::::: designate :: a :::::: signed :::: and ::: an :::::::: unsigned ::::::: integer ::::

type, :::::::::::: respectively, :::: that ::: are ::: at :::: least ::: as :::: wide ::: as :::: any ::::: basic :::::: integer ::::: type, :::: the ::::: types : Question 3. Shall _MAX and _MIN macros of the exact-with and least and fasted minimum-width types that are wider than UINTMAX_WIDTH be constrained not to be used during preprocessing as proposed in N2425? 2.3. Tighten the rules for least and fast minimum-width integer types When trying to formulate the features proposed in this paper, we noticed some lack of precisions and requirements for the least and minimum-width integers. For example no text currently explicitly says that the pairs of such designated types have to be the corresponding signed and unsigned integer types, nor is the existence of these types enforced, if the fixedwidth types exist. As such I don't think they are a big deal and everybody does this probably in a reasonable way. Nevertheless, I think it would help if these aspects were clarified. The corresponding text is relatively straight forward and can be found in the annex.

Question 4. Shall complementarity of signed and unsigned least and fast minimumwidth type pairs be enforced as proposed in N2425? Question 5. Shall the least and fast minimum-width type pairs be required if the corresponding exact-width type is provided as proposed in N2425? Question 6. Shall the value ranges for least and fast minimum-width types with width N < M be enforced as proposed in N2425?

New type aliases for the widest type pair

A new second paragraph should be added to 7.20.1.5 to introduce the new types. We only would require them to be at least as wide as all integer types that are introduced in <stdint.h>; that is they would be at least as wide as [u]intmax_t and all other optional exact-width and least and fasted minimum-width types that are provided by the plate-forme.

:::

The :::::: types ::::::::::::::: int_leastmax_t :::: and :::::::::::::::: uint_leastmax_t ::::::::: designate :: a :::::: signed ::::: and ::: an :::::::: unsigned :::::: integer ::::: type, :::::::::::: respectively, :::: that ::: are ::: at :::: least ::: as :::: wide ::: as :::: any :::::: integer ::::: type :::::: defined ::: by ::: the ::::::: header ::::::::::: <stdint.h>. :::::: These ::::: types :::: are :::::::: required. :

The note introduced previously is then amended and results in three notes and an example as follows.

::::::: Note 1: ::::: The :::::::: intmax_t :::: and :::::::::: uintmax_t ::::: types ::: are :::::::: intended ::: to ::::::: provide : a :::::::: fallback ::

for :::::::::::: applications ::::: that ::::: deal ::::: with :::::::: integers :::: for :::::: which ::::: they ::::: lack ::::::: specific :::::: type ::::::::::: information. :::: This ::::::: mainly :::::: occurs :::: for :::: two :::::::: different ::::::::: situations. :::::: First, ::: for :::::::: integers :::: that ::::::: appear ::: in ::::::::::: conditional :::::::: inclusion ::::: (#if :::::::::::: expressions, ::::::: 6.10.1) ::::: they :::::::: provide ::::::: fallback :::::: types :::: that :::::::: capture :::: the ::::::::::::::: implementation :::::::: specific ::::::::::: capabilities ::::::: during ::::::::: translation :::::: phase :: 4. :::::::: Second, ::: for ::::: some ::::::::: semantic :::: type :::::::::: definitions :::: that ::::::: resolve ::: to :::::::::::::: implementation :::::: specific :::::: types :::: there :::: are :: no ::::::: special ::::::::: provisions ::: for ::::::: printf, ::::: scanf ::: or :::::: similar ::::::::: functions. ::: In ::::::::: particular, :::: the :::::::: intmax_t :::: and :::::::::: uintmax_t ::::: types ::: are ::::::::: intended ::

to ::::::::: represent :::::: values :: of ::: all :::::: types :::::: listed ::::: above ::::: and :::: also :::: the ::::::::::: exact-width ::::::: integer ::::: types ::: for :: all :::::::: N ≤ 64. : :::::::

Note 2: :::::::::: Extended :::::: integer :::::: types ::::: that ::: are :::: not ::::::: referred ::: by :::: the :::::: above :::: list :::: and :::: that ::: are :::::: wider ::::: than ::::::: signed :::: long ::::: long :::: int ::::: may :::: also ::: be ::::: wider ::::: than :::::::::: intmax_t.

:::

The :::::: types :::::::: intmax_t :::: and ::::::::::::::: int_leastmax_t :::: may ::::: then ::: be :::::::: different. : ::::::: Note 3: ::::: The ::::::::::::::: int_leastmax_t :::: and ::::::::::::::::: uint_leastmax_t ::::: types :::: are ::::::::: intended ::: to :::::: provide :: a :::::::: fallback ::: for ::::::::::: applications ::::: that :::: deal ::::: with ::::::::: unknown ::::::: integer ::::: types ::::: that ::: are :::::::::: potentially ::::: wider ::::: than ::::::::: intmax_t :: or :::::::::: uintmax_t. : intmax t, a way out v.2 N2425:5 :::::::::

Example: :::: An ::::::::::::::: implementation :::: that :::: has ::::::::::: historically ::::: fixed ::: its ::::: type ::::::::: intmax_t ::

to :: a ::: 64 :::: bit :::::: type, ::::: and ::::: seeks ::: to ::::: add :: a ::::: 128 ::: bit :::::::: integer ::::::::::: exact-width :::::: type ::

to ::: its ::::::::: extended :::::::: integer :::::: types, ::::: may :::: do ::: so ::: by :::::::::: providing :::::: types ::::::::::: uint128_t, :::::::::::::::: uint_least128_t, :::::::::::::::: uint_least128_t, :::::::::::::::: uint_leastmax_t ::::: and ::: the :::::::::::::: corresponding ::::: signed :::::: types :::: and ::::::: macros :: of ::::::::: stdint.h :::: and :::::::::: inttypes.h ::::::: (7.8.1) ::::::: without ::::::::: breaking :::::: binary :::::::::::: compatibility. : :::::::::: Application ::::: code ::: can ::::: then ::::: query :::: the :::: type :::: and ::::: print :: it :: by :::::: using ::: the ::::::::::: appropriate ::::::: macros:

1 # include < stdint .h > 2 # include < stdio .h > 3 # include < inttypes .h > 4 # ifdef UINT128_MAX // ok , because # ifdef 5 typedef uint128_t bitset ; 6 # else 7 typedef uint_least64_t bitset ; 8 # endif 9 int main ( void ) { 10 bitset all = -1; 11 printf ( " the ␣ largest ␣ set ␣ is ␣ %# " PRIXLEASTMAX " \ n " , ( uint_leastmax_t ) all ) ; 12 }
The "recommended practice" introduced previously is then amended to make clear that [u]int_leastmax_t should never take part in any API or ABI.

:::::::::::::::

Implementations ::: and ::::::::::: applications :::::: should :::: not ::: use ::: the ::::: types ::::::::::::::: int_leastmax_t :::: and :::::::::::::::

uint_leastmax_t :: to :::::::: describe ::::::::::: application ::::::::::::: programmable ::::::::: interfaces.

To be fully operational, also some macros (_MAX etc) must be added to the text for stdint.h. These additions are straight forward and can be seen in the Appendix.

The "recommended practice" introduced previously is then amended to make clear that these macros should be used with care during preprocessing. Only the first six appear already in a published version of the standard, so we should not remove them, just declare them obsolescent. The others are current additions that are not yet published, so it is still time to completely replace them by the alternatives as proposed below.

The basic idea for all the replacements is to use type-generic interfaces.

-For the first six, standard functions already exist for the wide basic integer types. Since

[u]intmax_t have never been used in the field with other types than long or long long, this is just code duplication and the long long interface could clearly have worked all along. -In contrast to a catch-all solution with [u]intmax_t a type-generic solution always chooses the right interface for the type at hand and avoids useless conversion to (for the function argument) and from (for the return value) a wider type. -Just specifying type-generic macros and not specific functions, allows implementations to provide the functionally by functions that only have internal names or other mechanisms to their liking. This reduces the risk of name conflicts in the source (only may occur when the header is included) and during linking. -Type-generic macros are also more flexible, because implementations may add cases as they go, e.g if they introduce 128 bit floating types and integer types at the same time.

The text for all these type-generic interfaces are just additions and clearly identifiable in the appendix, so it is not repeated here. We explain them more in detail in the following sections.

For the {str|wcs}to[ui]max functions, the proposal is even simpler. The underlying family of functions cannot use the type of their argument to distinguish which type should be returned. If we want to phase out the [u]intmax_t types, such functions should simply not be used, but the appropriate function for the sought user type should be used directly.

Question 9. Shall we mark the {str|wcs}to[ui]max functions as obsolescent as proposed in N2425? 2.5.1. Type-generic macros for common integer operations -The interface imaxabs has the particularity that it is not defined for all inputs, because the mathematical value -INTMAX_MAX is out of range of the type intmax_t. This is an unnecessary restriction because:

-We know that the result is not negative, anyhow.

-The type uintmax_t comprises all the possible return values. Therefore we propose a type-generic macro that does not follow the previous interface where we have the same return type as the parameter type. Instead, it returns the unsigned type of the parameter type. Thereby the proposed type-generic solution is well-defined for all argument values.

Question 10. Shall we introduce the type-generic macro int_abs to the C standard as proposed in N2425?

Question 11. Shall we mark the imaxabs function as obsolescent as proposed in N2425?

-The interface imaxdiv even introduces a new type imaxdiv_t that is unnecessary because for all current implementations lldiv_t would do. Also the current version with a function has no defined behavior if the function is called with an unsigned argument that is larger intmax t, a way out v.2 N2425:7

than INTMAX_MAX. With our proposal it is a constraint violation to call the type-generic macro with a first unsigned and second signed argument where there is no signed supertype of the first argument type.

Question 12. Shall we introduce the type-generic macro int_div to the C standard as proposed in N2425?

Question 13. Shall we mark the imaxdiv function as obsolescent as proposed in N2425?

-As a little sidetrack we also propose to complete the picture by adding maximum and minimum type-generic macros to the same clause. The first can profit from a similar observation as int_abs. In case that the argument types are mixed signed and unsigned, it is sufficient to return an unsigned type to cover all the possible return values.

Question 14. Shall we introduce the type-generic macro int_max to the C standard as proposed in N2425?

-For the minimum, things are a bit more complicated. Here we have to require that a common signed supertype for the two argument types must exist.

Question 15. Shall we introduce the type-generic macro int_min to the C standard as proposed in N2425?

Integer-power type-generic macros

The current version of C2x proposes to add three new "integer-power function" of different flavor. In the current proposal the type of the integer parameter is intmax_t. This is not strictly necessary, long long should be largely enough. Our proposal uses an unspecified integer type that could vary between implementations, as long as it is wide enough to cover the possible values for the operation.

Question 16. Shall we replace the functions of type compoundn, rootn and pown by the type-generic macros as proposed in N2425?

Nearest integer type-generic macros

The newly introduced nearest integer type functions fromfp, fromfpx, ufromfp, and ufromfpx all use a return type of intmax_t, but for no compelling reason. As already observed for other functions, a return type of long long would generally be sufficient, to capture the possible return values. A type-generic macro has the advantage that the return type has not to be fixed once and for all, but that the addition of new floating point types to an implementation, would allow to define an appropriate return type that is adapted to the situation. Since some implementations that implement the previous API (and depending ABI) might already be out there, we propose to rename the feature such that it better fits into the established naming scheme.

Question 17. Shall we introduce the type-generic macros to{u}?int{x}? to the C standard as proposed in N2425?

Question 18. Shall we remove the {u}?fromfp{x}? functions from the C standard as proposed in N2425?

IMPACT

Existing implemenations and code

With such a change of the C standard, no existing ABI would have to change, and the preprocessor support for integer expressions could remain unchanged.

Since the concept of extended integer types is basically not yet used by implementations, there would also be no impact on the existing code base on existing implementations, even if they chose to extend their ABI by some wider integer types.

Extensibility of ABI's

This change allows platforms to add specifications of extended integer types more easily. In particular 128 or 256 bit types can be added to 64 bit ABI as long as a conforming naming scheme is chosen. Many implementations do so already in various forms and with nonuniform syntax. With this change they could just typedef their extented type to uint128_t, say, and provide the corresponding macros UINT128_MAX, UINT128_C, PRId128 etc. There is no need to extend the language to describe additional integer types (such as long long long), to add new number literals (-1ULLL) or to add printf conversion characters for these in the C standard. The use of implementation specific names (__int128 or __int128_t) and implementation specific format specifiers ("%Q") is largely sufficient if appropriately mapped by <stdint.h> typedef and macros.

ISO/IEC 9899:202x (E) Foreword ISO (the International Organization for Standardization) and IEC (the International Electrotechnical Commission) form the specialized system for worldwide standardization. National bodies that are member of ISO or IEC participate in the development of International Standards through technical committees established by the respective organization to deal with particular fields of technical activity. ISO and IEC technical committees collaborate in fields of mutual interest. Other international organizations, governmental and non-governmental, in liaison with ISO and IEC, also take part in the work. In the field of information technology, ISO and IEC have established a joint technical committee, ISO/IEC JTC 1.

The procedures used to develop this document and those intended for its further maintenance are described in the ISO/IEC Directives, Part 1. In particular, the different approval criteria needed for the different types of document should be noted. This document was drafted in accordance with the editorial rules of the ISO/IEC Directives, Part 2 (see www.iso.org/directives).

Attention is drawn to the possibility that some of the elements of this document may be the subject of patent rights. ISO and IEC shall not be held responsible for identifying any or all such patent rights. Details of any patent rights identified during the development of the document will be in the Introduction and/or on the ISO list of patent declarations received (see www.iso.org/patents).

Any trade name used in this document is information given for the convenience of users and does not constitute an endorsement. For an explanation of the voluntary nature of standards, the meaning of ISO specific terms and expressions related to conformity assessment, as well as information about ISO's adherence to the World Trade Organization (WTO) principles in the Technical Barriers to Trade (TBT), see the following URL: www.iso.org/iso/foreword.html. This document was prepared by Technical Committee ISO/IEC JTC 1, Information technology, Subcommittee SC 22, Programming languages, their environments and system software interfaces.

This fifth edition cancels and replaces the fourth edition, ISO/IEC 9899:2018. Major changes from the previous edition include:

-remove obsolete sign representations and integer width constraints -::::: allow ::::::::: extended :::::: integer :::::: types ::::: wider ::::: than ::::::::: intmax _ t :::: and :::::::::: uintmax _ t :

Format conversion of integer types <inttypes.h>

The header <inttypes.h> includes the header <stdint.h> and extends it with additional facilities provided by hosted implementations.

It declares functions for manipulating greatest-width integers and converting numeric character strings to greatest-width integers, and it declares the :::::::::: obsolescent type imaxdiv _ t which is a structure type that is the type of the value returned by the ::::::::::: obsolescent imaxdiv function.

For each type declared in <stdint.h>, it defines corresponding macros for conversion specifiers for use with the formatted input/output functions. 231) Forward references: integer types <stdint.h> (7.20), formatted input/output functions (7.21.6), formatted wide character input/output functions (7.29.2).

Macros for format specifiers

Each of the following object-like macros expands to a character string literal containing a conversion specifier, possibly modified by a length modifier, suitable for use within the format argument of a formatted input/output function when converting the corresponding integer type. These macro names have the general form of PRI (character string literals for the fprintf and fwprintf family) or SCN (character string literals for the fscanf and fwscanf family), 232) followed by the conversion specifier, followed by a name corresponding to a similar type name in 7.20.1. In these names, N represents the width of the type as described in 7.20.1. For example, PRIdFAST32 can be used in a format string to print the value of an integer of type int _ fast32 _ t.

The fprintf macros for signed integers are: For each type that the implementation provides in <stdint.h>, the corresponding fprintf macros shall be defined and the corresponding fscanf macros shall be defined unless the implementation does not have a suitable fscanf length modifier for the type. EXAMPLE #include <inttypes.h> #include <wchar.h> int main(void) { uintmax _ t i = UINTMAX _ MAX; // this type always exists wprintf(L"The largest integer value is %020" ISO/IEC 9899:202x (E) working draft -September 13, 2019 integers-new..exint-C2x N2425 PRIxMAX "\n", i);

:: ::: :: ::: :::::: wprintf : ( : L : " ::: The :::::::: largest ::::::::::::: preprocessor ::::::: integer :::::: value ::: is :::: %#" :::::::: PRIxMAX ::: "\ : n :: ", :: i : ) : ;

:: ::: :: ::: ::::::::::::::

uint _ leastmax _ t :: j :: = :::::::::::::::::: UINT _ LEASTMAX _ MAX : ; : ::: :: // : this type always exists :: ::: :: ::: ::::::

wprintf : ( : L : " ::: The :::::::: largest ::::::::: extended :::::::: integer ::::: value ::: is :::: %#" ::::::::::::: PRIxLEASTMAX ::: "\ : n :: ", :: j : ) : ; return 0; } 7.8.2 Functions for greatest-width integer types :::

The ::::::::: functions ::::::::: presented ::: in :::: this ::::::::: subclause ::: are ::::::::::: obsolescent ::::::: features ::::: that :::::: should :::: not :: be ::::: used :: in ::::: new ::::: code. :::: The ::::::::: functions :::::::: imaxabs :::: and ::::::::: imaxdiv ::: can ::: be :::::::: replaced ::: by :::: the ::::::::::: type-generic ::::::: macros ::::::::: int _ abs ::: and ::::::::: int _ div, :::::::::::: respectively, ::: as ::::::::::: introduced :::::: below, ::::: and ::::::::::: strtoimax, ::::::::::: strtoumax, ::::::::::: wcstoimax :::: and : :::::::::: wcstoumax ::: can ::::::: usually ::: be :::::::: replaced ::: by :::: their :::::::::::: counterparts ::: for ::::: long ::::: long :::::: types.

The imaxabs function Synopsis

#include <inttypes.h> intmax _ t imaxabs(intmax _ t j);

::

[[ :::::::::: deprecated :: ]] :::::::: intmax _ t :::::::: imaxabs : ( :::::::: intmax _ t :: j :

) : ;

Description

The imaxabs function computes the absolute value of an integer j. If the result cannot be represented, the behavior is undefined. 233)

Returns

The imaxabs function returns the absolute value.

The imaxdiv function Synopsis

#include <inttypes.h> imaxdiv _ t imaxdiv(intmax _ t numer, intmax _ t denom);

::

[[ :::::::::: deprecated :: ]] ::::::::: imaxdiv _ t :::::::: imaxdiv : ( :::::::: intmax _ t :::::: numer : , :::::::: intmax _ t :::::: denom : ) : ;

Description

The imaxdiv function computes numer / denom and numer % denom in a single operation.

Returns

The imaxdiv function returns a structure of type imaxdiv _ t comprising both the quotient and the remainder. The structure shall contain (in either order) the members quot (the quotient) and rem (the remainder), each of which has type intmax _ t. If either part of the result cannot be represented, the behavior is undefined. ISO/IEC 9899:202x (E)

The

Description

The strtoimax and strtoumax functions are equivalent to the strtol, strtoll, strtoul, and strtoull functions, except that the initial portion of the string is converted to intmax _ t and uintmax _ t representation, respectively.

Returns

The

Description

The wcstoimax and wcstoumax functions are equivalent to the wcstol, wcstoll, wcstoul, and wcstoull functions except that the initial portion of the wide string is converted to intmax _ t and uintmax _ t representation, respectively.

Returns

The Forward references: the wcstol, wcstoll, wcstoul, and wcstoull functions (7.29.4.1.3). :

Type-generic macros for common integer operations

::::

This :::::: clause :::::::: presents :::::::::::: type-generic :::::::: macros :::: that ::::: shall ::::::: behave ::: as :: if :: a :::::::: function ::::: with :::: the ::::::::: indicated :::::::::

prototype ::::: were :::::: called. ::::: The ::::: types :: T ::::: (and : S ::::: were ::::::::::: applicable) ::::: shall :: be :::: any :::::::::: supported ::::::: integer ::::: type ::::

with :: a :::::::::: conversion ::::: rank :: of :::: int :: or ::::::: higher. :::::: When :::::: called, :::: the ::::::::::::: corresponding ::::::::: prototype ::: to :: be :::::::: applied : is ::::::::::: determined ::: by :::: the ::::::::: promoted ::::: type :: of :::: the :::: first :::::: macro ::::::::: argument :::: for :: T, ::::: and, :: if ::::::::: applicable ::: by :::: the If : T :: is : a ::::: signed :::: type, :::: even :: the ::::::: negative :: of :: the :::::::: minimum :::: value :: of : T ::: fits ::: into :: R.

235) :

If ::: one :: of : T ::: and :: S :: is : a ::::: signed :::: type ::: and ::: the :::: other : is :::::::: unsigned, ::: the ::::::: maximum :: of ::: the ::::: result : is ::::: never :::::: negative ::: and :: is :::: thus :::::

within :: the ::::: value :::: range :: of : R.

236) :

If : T ::: and :: S :: are ::: the ::::: widest ::::: signed ::: and ::::::: unsigned :::::: integer :::: types, ::::::::: respectively, :::: such : a :::: type ::: does ::: not :::: exist. working draft -September 13, 2019 integers-new..exint-C2x N2425

Returns

The cbrt functions return x 1 3 . Synopsis replace

#include <stdint.h> #include <math.h> double compoundn(double x, intmax _ t n); float compoundnf(float x, intmax _ t n); long double compoundnl(long double x, intmax _ t n); #ifdef __ STDC _ IEC _ 60559 _ DFP __ _ Decimal32 compoundnd32( _ Decimal32 x, intmax _ t n); _ Decimal64 compoundnd64( _ Decimal64 x, intmax _ t n); _ Decimal128 compoundnd128( _ Decimal128 x, intmax _ t n); #endif

Description

The compute 1 plus x, raised to the power n. A domain error occurs if x < -1. A range error may occur if n is too large, depending on x. A pole error may occur if x equals -1 and n < 0.

Returns

The return (1 + x) n .

The

Description

The fabs functions compute the absolute value of a floating-point number x.

Returns

The fabs functions return |x|.

Description

The hypot functions compute the square root of the sum of the squares of x and y, without undue overflow or underflow. A range error may occur.

ISO/IEC 9899:202x (E)

Returns

The hypot functions return x 2 + y 2 .

The

Description

The pow functions compute x raised to the power y. A domain error occurs if x is finite and negative and y is finite and not an integer value. A range error may occur. A domain error may occur if x is zero and y is zero. A domain error or pole error may occur if x is zero and y is less than zero.

Returns

The pow functions return x y .

Synopsis replace

Description

The compute x raised to the th power. A range error may occur. A pole error may occur if x equals 0 and n < 0.

Returns

The return x n . #endif § 7.12.7.5 Library ISO/IEC 9899:202x (E)

working draft -September 13, 2019 integers-new..exint-C2x N2425

Description

The powr functions compute x raised to the power y as e y log x . A domain error occurs if x < 0 or if x and y are both zero. A range error may occur. A pole error may occur if x equals zero and finite y < 0.

Returns

The powr functions return x y .

Synopsis replace

#include <stdint.h> #include <math.h> double rootn(double x, intmax _ t n); float rootnf(float x, intmax _ t n); long double rootnl(long double x, intmax _ t n); #ifdef __ STDC _ IEC _ 60559 _ DFP __ _ Decimal32 rootnd32( _ Decimal32 x, intmax _ t n); _ Decimal64 rootnd64( _ Decimal64 x, intmax _ t n); _ Decimal128 rootnd128( _ Decimal128 x, intmax _ t n); #endif

Description

The compute the principal th root of x. A domain error occurs if n is 0 or if x < 0 and n is even. A range error may occur if n is -1. A pole error may occur if x equals zero and n < 0.

Returns

The return x

Description

The rsqrt functions compute the reciprocal of the square root of the argument. A domain error occurs if the argument is less than zero. A pole error may occur if the argument equals zero.

Returns

The rsqrt functions return

Description

The lround and llround functions round their argument to the nearest integer value, rounding halfway cases away from zero, regardless of the current rounding direction. If the rounded value is outside the range of the return type, the numeric result is unspecified and a domain error or range error may occur.

Returns

The lround and llround functions return the rounded integer value.

7.12.9.

Description

The roundeven functions round their argument to the nearest integer value in floating-point format, rounding halfway cases to even (that is, to the nearest value that is an even integer), regardless of the current rounding direction.

Returns

The roundeven functions return the rounded integer value.

7.12.9.9 The trunc functions Synopsis

Description

The trunc functions round their argument to the integer value, in floating format, nearest to but no larger in magnitude than the argument.

Returns

The trunc functions return the truncated integer value.

Synopsis replace Description § 7.12.9.9 Library ISO/IEC 9899:202x (E)

working draft -September 13, 2019 integers-new..exint-C2x N2425

The fromfp and ufromfp functions round x, using the math rounding direction indicated by round, to a signed or unsigned integer, respectively, of width bits, and return the result value in the integer type designated by intmax _ t or uintmax _ t, respectively. If the value of the round argument is not equal to the value of a math rounding direction macro, the direction of rounding is unspecified. If the value of width exceeds the width of the function type, the rounding is to the full width of the function type. The fromfp and ufromfp functions do not raise the "inexact" floating-point exception. If x is infinite or NaN or rounds to an integral value that is outside the range of any supported integer type of the specified width, or if width is zero, the functions return an unspecified value and a domain error occurs.

Returns

The fromfp and ufromfp functions return the rounded integer value.

Upward rounding of double x to type int, without raising the "inexact" floating-point exception, is achieved by

Synopsis replace Description

The fromfpx and ufromfpx functions differ from the fromfp and ufromfp functions, respectively, only in that the fromfpx and ufromfpx functions raise the "inexact" floating-point exception if a rounded result not exceeding the specified width differs in value from the argument x.

Returns

The fromfpx and ufromfpx functions return the rounded integer value.

Conversions to integer types that are not required to raise the inexact exception can be done simply by rounding to integral value in floating type and then converting to the target integer type. For example, the conversion of long double x to uint64 _ t, using upward rounding, is done by

Description

The fmod functions compute the floating-point remainder of x/y.

Returns

The fmod functions return the value xny, for some integer n such that, if y is nonzero, the result has the same sign as x and magnitude less than the magnitude of y. If y is zero, whether a domain error occurs or the fmod functions return zero is implementation-defined.

Integer types <stdint.h>

The header <stdint.h> declares sets of integer types having specified widths, and defines corresponding sets of macros. 282) It also defines macros that specify limits of integer types corresponding to types defined in other standard headers.

Types are defined in the following categories:

-integer types having certain exact widths;

-integer types having at least certain specified widths;

-fastest integer types having at least certain specified widths;

-integer types wide enough to hold pointers to objects;

-integer types having greatest width.

(Some of these types may denote the same type.)

Corresponding macros specify limits of the declared types and construct suitable constants.

For each type described herein that the implementation provides, 283) <stdint.h> shall declare that typedef name and define the associated macros. Conversely, for each type described herein that the implementation does not provide, <stdint.h> shall not declare that typedef name nor shall it define the associated macros. An implementation shall provide those types described as "required", but need not provide any of the others (described as "optional").

The feature test macro __ STDC _ VERSION _ STDINT _ H __ expands to the token yyyymmL.

Integer types

When typedef names differing only in the absence or presence of the initial u are defined, they shall denote corresponding signed and unsigned types as described in 6.2.5; an implementation providing one of these corresponding types shall also provide the other.

In the following descriptions, the symbol N represents an unsigned decimal integer with no leading zeros (e.g., 8 or 24, but not 04 or 048).

Exact-width integer types

The typedef name intN _ t designates a signed integer type with width N and no padding bits. Thus, int8 _ t denotes such a signed integer type with a width of exactly 8 bits.

The typedef name uintN _ t designates an unsigned integer type with width N and no padding bits. Thus, uint24 _ t denotes such an unsigned integer type with a width of exactly 24 bits.

These types are optional. However, if an implementation provides integer types with widths of 8, 16, 32, or 64 bits, and no padding bits, it shall define the corresponding typedef names.

Minimum-width integer types

The typedef name int _ leastN _ t designates a signed integer type with a width of at least N, such that no signed integer type with lesser size has at least the specified width. Thus, int _ least32 _ t denotes a signed integer type with a width of at least 32 bits.

The typedef name uint _ leastN _ t designates an unsigned integer type with a width of at least N, such that no unsigned integer type with lesser size has at least the specified width. Thus, uint _ least16 _ t denotes an unsigned integer type with a width of at least 16 bits. and ::::::::::: int _ least :: M _ t ::: are ::::::::: provided ::: for :::::::: N < M , ::: the :::::: width :: of :::: the ::::::: former :: is ::: less ::::: than ::: or ::::: equal :: to :::: the :::::

width ::: of ::: the ::::: latter. :

The following types are required:

282) See "future library directions" (7.31.12). 283) Some of these types might denote implementation-defined extended integer types. as ::: are :::: the ::::: types ::::::::::: int _ least :: N _ t :::: and ::::::::::: uint _ least :: N _ t ::: for :: all ::: N :: for :::::: which :::: the ::::::::::: exact-width :::::: types :::

int :: N _ t :::: and ::::: uint : N _ t ::: are ::::::::: provided. All other types of this form are optional.

Fastest minimum-width integer types

Each of the following types designates an integer type that is usually fastest 284) to operate with among all integer types that have at least the specified width.

The typedef name int _ fastN _ t designates the fastest signed integer type with a width of at least N. The typedef name uint _ fastN _ t designates the fastest unsigned integer type with a width of at least N. M _ t ::: are ::::::::: provided ::: for :::::::: N < M , ::: the :::::: width :: of ::: the ::::::: former :: is :::: less :::: than ::: or ::::: equal ::: to ::: the :::::: width ::

of ::: the :::::: latter.

The following types are required: as ::: are ::: the ::::: types ::::::::: int _ fast :: N _ t ::: and :::::::::: uint _ fast :: N _ t ::: for :: all :: N :: for :::::: which ::: the ::::::::::: exact-width ::::: types :::: int :: N _ t :::

and ::::: uint :: N _ t ::: are ::::::::: provided. : All other types of this form are optional.

Integer types capable of holding object pointers

The following type designates a signed integer type with the property that any valid pointer to void can be converted to this type, then converted back to pointer to void, and the result will compare equal to the original pointer:

intptr _ t
The following type designates an unsigned integer type with the property that any valid pointer to void can be converted to this type, then converted back to pointer to void, and the result will compare equal to the original pointer:

uintptr _ t
These types are optional.

Greatest-width integer types

The following type designates a signed integer type capable of representing any value of any signed integer type: The following type designates :::: The ::::: types ::::::::: intmax _ t :::: and :::::::::: uintmax _ t ::::::::: designate : a ::::::: signed wint _ t 284) The designated type is not guaranteed to be fastest for all purposes; if the implementation has no clear grounds for choosing one type over another, it will simply pick some integer type satisfying the signedness and width requirements.

ISO/IEC 9899:202x (E)

working draft -September 13, 2019 integers-new..exint-C2x N2425

::::

and, ::::::::: provided :::: they ::::: exist, ::::::::: intptr _ t :::: and ::::::::::: uintptr _ t. :::::: These ::::: types ::: are ::::::::: required.

:::

The :::::: types :::::::::::::::: int _ leastmax _ t :::: and ::::::::::::::::: uint _ leastmax _ t ::::::::: designate :: a :::::: signed ::::: and an unsigned integer typecapable of representing any value of any unsigned integer type: , :::::::::::: respectively, :::: that ::: are :: at ::::: least ::

as ::::: wide :: as :::: any ::::::: integer :::: type ::::::: defined ::: by ::: the ::::::: header <stdint.h> . :::::: These ::::: types ::: are ::::::::: required. : NOTE 1 :::

The ::::::: intmax _ t ::: and ::::::::: uintmax _ t :::: types ::: are ::::::: intended :: to :::::: provide : a :::::: fallback ::: for ::::::::: applications ::: that :::: deal :::: with :::::: integers ::

for ::::: which :::: they ::: lack :::::: specific :::: type :::::::::: information. :::: This ::::: mainly :::::: occurs :: for :::: two :::::: different :::::::: situations. ::::: First, ::: for :::::: integers :::: that :::::

appear :: in :::::::: conditional ::::::: inclusion : ( :: #if ::::::::: expressions, ::::: 6.10.1) ::: they :::::: provide :::::: fallback :::: types ::: that :::::: capture ::: the ::::::::::: implementation :::::: specific ::::::::

capabilities ::::: during :::::::: translation ::::: phase :: 4. :::::: Second, :: for :::: some ::::::: semantic :::: type :::::::: definitions ::: that ::::: resolve :: to :::::::::::: implementation :::::: specific ::::

types :::: there ::: are :: no ::::: special :::::::: provisions ::: for :::::: printf, ::::: scanf :: or ::::: similar :::::::: functions. :: In :::::::: particular, ::: the ::::::: intmax _ t ::: and ::::::::: uintmax _ t ::::

types :: are ::::::: intended :: to ::::::: represent ::::: values :: of :: all :::: types :::: listed ::::: above ::: and ::: also ::: the ::::::::: exact-width ::::: integer :::: types ::: for :: all :::::: N ≤ 64. : NOTE 2 :::::: Extended :::::: integer :::: types ::: that ::: are ::: not :::::: referred :: by ::: the :::: above ::: list ::: and ::: that ::: are :::: wider :::: than ::::: signed :::: long :::: long ::: int :::: may ::: also :: be :::: wider :::: than :::::::: intmax _ t. ::: The :::: types ::::::: intmax _ t :::: and :::::::::::: int _ leastmax _ t :::: may ::: then :: be ::::::: different. : NOTE 3 :::

The :::::::::::: int _ leastmax _ t ::: and :::::::::::::: uint _ leastmax _ t :::: types ::: are ::::::: intended :: to :::::: provide : a :::::: fallback ::: for ::::::::: applications ::: that :::: deal :::

with :::::::: unknown ::::: integer :::: types ::: that ::: are :::::::: potentially :::: wider :::: than ::::::: intmax _ t :: or ::::::::: uintmax _ t. EXAMPLE :: An :::::::::::: implementation ::: that ::: has ::::::::: historically :::: fixed :: its :::: type ::::::: intmax _ t :: to :: a :: 64 :: bit :::: type, ::: and ::::: seeks :: to ::: add : a ::: 128 ::: bit ::::: integer ::::::::: exact-width :::: type :: to :: its ::::::: extended :::::: integer ::::: types, :::: may :: do :: so ::: by :::::::: providing :::: types ::::::::: uint128 _ t, :::::::::::::: uint _ least128 _ t, : ::::::::::::: uint _ least128 _ t, :::::::::::::: uint _ leastmax _ t ::: and ::: the ::::::::::: corresponding ::::: signed :::: types ::: and :::::: macros :: of <stdint.h> ::: and <inttypes.h> of ::::::: integer :::::: literals :: is ::::::::::: consistently :::::::: accepted ::: by ::: all ::::::::::: compilation ::::::: phases, ::::: even :: if ::::::::: intmax _ t :: is :::::: chosen ::: to ::

be :::::: wider :::: than ::::::: signed ::::: long ::::: long :::: int. :::::::::::::::: Implementations :::: and ::::::::::: applications ::::::: should :::: not ::: use ::: the :::::: types :::::::::::::::

int _ leastmax _ t :::: and ::::::::::::::::: uint _ leastmax _ t :: to :::::::: describe :::::::::: application :::::::::::::: programmable ::::::::: interfaces. 285)

Widths of specified-width integer types

The following object-like macros specify the width of the types declared in <stdint.h>. Each macro name corresponds to a similar type name in 7.20.1.

Each :::::: Unless :::::::: specified :::::::::: otherwise, :::: each : instance of any defined macro shall be replaced by a constant expression suitable for use in #if preprocessing directives. Its implementation-defined value shall be equal to or greater than the value given below, except where stated to be exactly the given value. An implementation shall define only the macros corresponding to those typedef names it actually provides. 286)

Width of exact-width integer types

285)

:::

This ::::::: document :::: does ::: not ::: use :::: them ::::: further :: in ::: any :: of :: its :::::: clauses.

Width of other integer types

The following object-like macros specify the width of integer types corresponding to types defined in other standard headers.

Each instance of these macros shall be replaced by a constant expression suitable for use in #if preprocessing directives. Its implementation-defined value shall be equal to or greater than the corresponding value given below. An implementation shall define only the macros corresponding to those typedef names it actually provides.

Macros for integer constants

The following function-like macros expand to integer constants suitable for initializing objects that have integer types corresponding to types defined in <stdint.h>. Each macro name corresponds to a similar type name in 7.20.1.2 or 7.20.1.5. ::: For ::::: types :::::: wider ::::: than :::::::::: uintmax _ t, :::: the ::::::: macros :::: shall ::::: only ::

be ::::::: defined :: if :::: the :::::::::::::: implementation ::::::::: provides :::::: integer ::::::: literals ::: for :::: the :::: type :::: that ::: are :::::::: suitable :: to ::: be ::::: used ::

in :::: #if :::::::::::: preprocessing :::::::::: directives. :::::::::: Otherwise, :::: the ::::::::: definition :: of ::::: these ::::::: macros :: is ::::::::::: mandatory ::: for ::: any ::: of :::

the ::::: types :::: that ::: are ::::::::: provided ::: by ::: the ::::::::::::::: implementation. :

The argument in any instance of these macros shall be an unsuffixed integer constant (as defined in 6.4.4.1) with a value that does not exceed the limits for the corresponding type.

Each invocation of one of these macros shall expand to an integer constant expression suitable for use in #if preprocessing directives. The type of the expression shall have the same type as would an expression of the corresponding type converted according to the integer promotions. The value of the expression shall be that of the argument.

Macros for minimum-width integer constants

The : If :::::::: defined, ::: the : macro INTN _ C(value) expands to an integer constant expression corresponding to the :::::::::

promoted type int _ leastN _ t. The : If :::::::: defined, :::: the macro UINTN _ C(value) expands to an integer constant expression corresponding to the ::::::::: promoted : type uint _ leastN _ t. For example, if EXAMPLE : If uint _ least64 _ t is a name for the type unsigned long long int, then UINT64 _ C(0x123) might expand to the integer constant 0x123ULL.

Macros for greatest-width integer constants

The following macro expands to an integer constant expression having the value specified by its argument and the type intmax _ t:

INTMAX _ C(value)

The following macro expands to an integer constant expression having the value specified by its argument and the type uintmax _ t:

UINTMAX _ C(value)

: If ::::::::: defined, ::: the :::::::::: following ::::::: macro :::::::: expands ::: to ::: an ::::::: integer :::::::: constant ::::::::::: expression ::::::: having :::: the :::::: value :::::::: specified ::: by :: its ::::::::: argument :::: and ::: the ::::: type :::::::::::::::: int _ leastmax _ t: : :: ::: :::::::::::::

INT _ LEASTMAX _ C : (value : ) :
If ::::::::: defined, ::: the :::::::::: following ::::::: macro :::::::: expands ::: to ::: an ::::::: integer :::::::: constant ::::::::::: expression ::::::: having :::: the :::::: value :::::::: specified ::: by :: its ::::::::: argument :::: and ::: the ::::: type ::::::::::::::::: uint _ leastmax _ t: : :: ::: ::::::::::::::

UINT _ LEASTMAX _ C : (value : )

Maximal and minimal values of integer types

For all integer types for which there is a macro with suffix _ WIDTH holding the width, maximum macros with suffix _ MAX and, for all signed types, minimum macros with suffix _ MIN are defined as by 5.2.4.2. If it is unspecified if a type is signed or unsigned and the implementation has it as an unsigned type, a minimum macro with extension _ MIN, and value 0 of the corresponding type is defined. :::

For ::::: types ::::: wider ::::: than :::::::::: uintmax _ t :::: and ::: for :::::: which ::: the ::::::::::::: corresponding ::::::::: minimum :::::: width ::::::: integer ::::::: constant ::::::: macro :::: with :::::: suffix ::: _ C :: is ::: not :::::::: defined, ::::::: 7.20.4.1 :::: and :::::::: 7.20.4.2, :::: the ::::::: macros ::: are ::: not ::::::::::: necessarily :::::::

suitable :: to ::: be :::: used ::: in ::: #if ::::::::::::: preprocessing :::::::::: directives. :

260 Library § 7.20.5

N2425 integers-new..exint-C2x working draft -September 13, 2019

ISO/IEC 9899:202x (E) EXAMPLE : If :::::::::::: UINTMAX _ WIDTH :: is :: 64, ::: no ::::: literals ::::: wider ::: than ::: 64 :::: exist, ::: and ::::::: int128 _ t :::: and :::::::: uint128 _ t ::: are ::::: names :: for :::::: extend ::::: integer ::::: types, ::: then ::: the ::::::: following ::: are :::: valid :::::::: definitions. This :::::::: constraint ::::: reflects ::: the ::: fact :::: that :::: these :::::: macros :::: may :::: have :::::::: numerical ::::: values ::: that :::::: exceed ::: the ::::: largest :::: value :::: that :: is ::::::::::

representable ::::: during ::::::::::: preprocessing. :: In ::: that :::: case :::: these ::::::: constants ::: will ::::::: generally :: be :::::::: expressed :: by ::::::: constant :::::::: expressions :::: that ::

are :::: more ::::::: complex ::: and :: not :::::: suitable ::: for ::::::::::: preprocessing. If at least one argument for a generic parameter is complex, then use of the macro invokes a complex function; otherwise, use of the macro invokes a real function.

For each unsuffixed function in <math.h> without a c-prefixed counterpart in <complex.h> (except functions that round result to narrower type, modf, and canonicalize), the corresponding typegeneric macro has the same name as the function. These type-generic macros are: If all arguments for generic parameters are real, then use of the macro invokes a real function (provided <math.h> defines a function of the determined type); otherwise, use of the macro is undefined.

For each unsuffixed function in <complex.h> that is not a c-prefixed counterpart to a function in <math.h>, the corresponding type-generic macro has the same name as the function. These type-generic macros are:

carg cimag conj cproj creal
Use of the macro with any argument of standard floating or complex type invokes a complex function. Use of the macro with an argument of decimal floating type is undefined.

The functions that round result to a narrower type have type-generic macros whose names are obtained by omitting any suffix from the function names. Thus, the macros with f or d prefix are: In ::: the ::::::::: following ::::::::::::: specifications ::: the ::::: type :: T :: of ::: the ::::: first ::::::::: prototype :::::::::: parameter : x :::::::::::: corresponds :: to :: a :::: real ::::::: floating ::::: point ::::: type :::: that :: is :::::::::: supported :: by :::: the ::::::::::::::: implementation, :: or ::: to ::: an :::::: imple ::::: men :: ta ::::::::::: tion-defined ::: set § 7.25.1 Library ISO/IEC 9899:202x (E) working draft -September 13, 2019 integers-new..exint-C2x N2425

Future library directions

The following names are grouped under individual headers for convenience. All external names described below are reserved no matter what headers are included by the program.

Complex arithmetic <complex.h>

The function names

cacospi casinpi catanpi ccompoundn ccospi cerfc cerf cexp10m1 cexp10 cexp2m1 cexp2 cexpm1 clgamma clog10p1 clog10 clog1p clog2p1 clog2 clogp1 cpown cpowr crootn crsqrt csinpi ctanpi ctgamma
and the same names suffixed with f or l may be added to the declarations in the <complex.h> header.

Character handling <ctype.h>

Function names that begin with either is or to, and a lowercase letter may be added to the declarations in the <ctype.h> header.

Errors <errno.h>

Macros that begin with E and a digit or E and an uppercase letter may be added to the macros defined in the <errno.h> header.

Floating-point environment <fenv.h>

Macros that begin with FE _ and an uppercase letter may be added to the macros defined in the <fenv.h> header.

Characteristics of floating types <float.h>

Macros that begin with DBL _ , DEC32 _ , DEC64 _ , DEC128 _ , DEC _ , FLT _ , or LDBL _ and an uppercase letter may be added to the macros defined in the <float.h> header.

Format conversion of integer types <inttypes.h>

Macros that begin with either PRI or SCN, and either a lowercase letter or X may be added to the macros defined in the <inttypes.h> header.

Function names that begin with str, or wcs and a lowercase letter may be added to the declarations in the <inttypes.h> header.

:::

The ::::: type :::::::::: imaxdiv _ t :::: and ::: the ::::::::: functions ::::::::: imaxabs, :::::::: imaxdiv, ::::::::::: strtoimax, ::::::::::: strtoumax, :::::::::: wcstoimax :::: and :::::::::: wcstoumax ::: are ::::::::::: obsolescent :::::::: features.

Localization <locale.h>

Macros that begin with LC _ and an uppercase letter may be added to the macros defined in the <locale.h> header.

Mathematics <math.h>

Macros that begin with FP _ or MATH _ and an uppercase letter may be added to the macros defined in the <math.h> header.

Use of the DECIMAL _ DIG macro is an obsolescent feature. A similar type-specific macro, such as LDBL _ DECIMAL _ DIG, can be used instead.

Function names that begin with is and a lowercase letter may be added to the declarations in the <math.h> header.

ISO/IEC 9899:202x (E)

The function names and the same names suffixed with f, l, d32, d64, or d128 may be added to the <math.h> header. The cr prefix is intended to indicate a correctly rounded version of the function.

Signal handling <signal.h>

Macros that begin with either SIG and an uppercase letter or SIG _ and an uppercase letter may be added to the macros defined in the <signal.h> header.

Atomics <stdatomic.h>

Macros that begin with ATOMIC _ and an uppercase letter may be added to the macros defined in the <stdatomic.h> header. Typedef names that begin with either atomic _ or memory _ , and a lowercase letter may be added to the declarations in the <stdatomic.h> header. Enumeration constants that begin with memory _ order _ and a lowercase letter may be added to the definition of the memory _ order type in the <stdatomic.h> header. Function names that begin with atomic _ and a lowercase letter may be added to the declarations in the <stdatomic.h> header.

The macro ATOMIC _ VAR _ INIT is an obsolescent feature.

Boolean type and values <stdbool.h>

The ability to undefine and perhaps then redefine the macros bool, true, and false is an obsolescent feature.

Integer types <stdint.h>

Typedef names beginning with int or uint and ending with _ t may be added to the types defined in the <stdint.h> header. Macro names beginning with INT or UINT and ending with _ MAX, _ MIN, _ WIDTH, or _ C may be added to the macros defined in the <stdint.h> header.

Input/output <stdio.h>

Lowercase letters may be added to the conversion specifiers and length modifiers in fprintf and fscanf. Other characters may be used in extensions.

The use of ungetc on a binary stream where the file position indicator is zero prior to the call is an obsolescent feature.

General utilities <stdlib.h>

Function names that begin with str or wcs and a lowercase letter may be added to the declarations in the <stdlib.h> header.

Invoking realloc with a size argument equal to zero is an obsolescent feature.

String handling <string.h>

Function names that begin with str, mem, or wcs and a lowercase letter may be added to the declarations in the <string.h> header.

Date and time <time.h>

Macros beginning with TIME _ and an uppercase letter may be added to the macros in the 7.12.10.2, F.10.7.2, 7.12.10.3, F.10.7.3 minNum fmin 7.12.12.3, F.10.9.3 maxNum fmax 7.12.12.2, F.10.9.2 minNumMag fminmag 7.12.12.5, F.10.9.5 maxNumMag fmaxmag 7.12.12.4, F.10.9.4 scaleB scalbn, scalbln 7.12.6.19, F.10.3.19 logB logb, ilogb, llogb 7.12.6.17, F.10.3.17, 7.12.6.8, F.10.3.8, 7.12.6.10, F.10.3.10 addition + , fadd, faddl, daddl 6.5.6, 7.12. The integer constant 10 provides the radix operation defined in IEC 60559 for decimal floating-point arithmetic.

The samequantumdN functions (7.12.15.2) provide the sameQuantum operation defined in IEC 60559 for decimal floating-point arithmetic.

The fe _ dec _ getround (7.6.5.3) and fe _ dec _ setround (7.6.5.6) functions provide the getDeci-malRoundingDirection and setDecimalRoundingDirection operations defined in IEC 60559 for decimal floating-point arithmetic. The macros (7.6) FE _ DEC _ DOWNWARD, FE _ DEC _ TONEAREST, FE _ DEC _ TONEARESTFROMZERO, FE _ DEC _ TOWARDZERO, and FE _ DEC _ UPWARD, which are used in conjunction with the fe _ dec _ getround and fe _ dec _ setround functions, represent the IEC 60559 rounding-direction attributes roundTowardNegative, roundTiesToEven, roundTiesToAway, round-TowardZero, and roundTowardPositive, respectively.

The quantumdN (7.12.15.3) and llquantexpdN (7.12.15.4) functions compute the quantum and the (quantum) exponent q defined in IEC 60559 for decimal numbers viewed as having integer significands.

The encodedecdN (7.12.16.1) and decodedecdN (7.12.16.2) functions provide the encodeDecimal and decodeDecimal operations defined in IEC 60559 for decimal floating-point arithmetic.

The encodebindN (7.12.16.3) and decodebindN (7.12.16.4) functions provide the encodeBinary and decodeBinary operations defined in IEC 60559 for decimal floating-point arithmetic.

The C functions :::

and :::::::::::: type-generic :::::: macros : in the following table provide operations recommended by IEC 60559 and similar operations. Correct rounding, which IEC 60559 specifies for its operations, is not required for the C functions in the table. See also 7.31.8. IEC 60559 operation C function or macro Clause exp exp 7.12.6.1, F.10.3.1 expm1 expm1 7.12.6.6, F.10.3.6 exp2 exp2 7.12.6.4, F.10.3.4 exp2m1 exp2m1 7.12.6.5, F.10.3.5 exp10 exp10 7.12.6.2, F.10.3.2 exp10m1 exp10m1 7.12.6.3, F.10.3.3 log log 7.12.6.11, F.10.3.11 log2 log2 7.12.6.15, F.10.3.15 log10 log10 7.12.6.12, F.10.3.12 logp1 log1p, logp1 7.12.6.14, F.10.3.14 log2p1 log2p1 7.12.6.16, F.10.3.16 log10p1 log10p1 7.12.6.13, F.10.3.13 hypot hypot 7.12.7.3, F.10.4.4 rSqrt rsqrt 7.12.7.6, F.10.4.9 compound .12.7.4, F.10.4.5 powr powr 7.12.7.5, F.10.4.7 sin sin 7.12.4.6, F.10.1.6 cos cos 7.12.4.5, F.10.1.5 tan tan 7.12.4.7, F.10.1.7 sinPi sinpi 7.12.4.13, F.10.1.13 cosPi cospi 7.12.4.12, F.10.1.12 tanpi 7.12.4.14, F.10.1.14 asinpi 7.12.4.9, F.10.1.9 acospi 7.12.4.8, F.10.1.8 atanPi atanpi 7.12.4.10, F.10.1.10 atan2Pi atan2pi 7.12.4.11, F.10.1.11 asin asin 7.12.4.2, F.10.1.2 ... continued ...

ISO/IEC 9899:202x (E)

... continued ... IEC 60559 operation C function Clause acos acos 7.12.4.1, F.10.1.1 atan atan 7.12.4.3, F.10.1.3 atan2 atan2 7.12.4.4, F.10.1.4 sinh sinh 7.12.5.5, F.10.2.5 cosh cosh 7.12.5.4, F.10.2.4 tanh tanh 7.12.5.6, F.10.2.6 asinh asinh 7.12.5.2, F.10.2.2 acosh acosh 7.12.5.1, F.10.2.1 atanh atanh 7.12.5.3, F.10.2.3

F.4 Floating to integer conversion

If the integer type is _ Bool, 6.3.1.2 applies and the conversion raises no floating-point exceptions if the floating-point value is not a signaling NaN. Otherwise, if the floating value is infinite or NaN or if the integral part of the floating value exceeds the range of the integer type, then the "invalid" floating-point exception is raised and the resulting value is unspecified. Otherwise, the resulting value is determined by 6.3.1.4. Conversion of an integral floating value that does not exceed the range of the integer type raises no floating-point exceptions; whether conversion of a non-integral floating value raises the "inexact" floating-point exception is unspecified. 389)

F.5 Conversions between binary floating types and decimal character sequences

The <float.h> header defines the macro Conversions of types with IEC 60559 binary formats to character sequences with more than CR _ DECIMAL _ DIG significant decimal digits shall correctly round to CR _ DECIMAL _ DIG significant digits and pad zeros on the right.

Conversions from character sequences with more than CR _ DECIMAL _ DIG significant decimal digits to types with IEC 60559 binary formats shall correctly round to an intermediate character sequence with CR _ DECIMAL _ DIG significant decimal digits, according to the applicable rounding direction, and correctly round the intermediate result (having CR _ DECIMAL _ DIG significant decimal digits) to the destination type. The "inexact" floating-point exception is raised (once) if either conversion is inexact. 390) (The second conversion may raise the "overflow" or "underflow" floating-point exception.)

The specification in this subclause assures conversion between IEC 60559 binary format and decimal character sequence follows all pertinent recommended practice. It also assures conversion from IEC 60559 format to decimal character sequence with at least T _ DECIMAL _ DIG digits and back, using to-nearest rounding, is the identity function, where T is the macro prefix for the format.

389) IEC 60559 recommends that implicit floating-to-integer conversions raise the "inexact" floating-point exception for non-integer in-range values. In those cases where it matters, library functions can be used to effect such conversions with or without raising the "inexact" floating-point exception. See fromfp ::::: toint , ufromfp :::::: touint , fromfpx :::::: tointx , ufromfpx

:

  If :::: the :::::: macros ::::::::::::::: INT_LEASTMAX_C ::: and :::::::::::::::: UINT_LEASTMAX_C ::: are ::: not :::::::: defined, ::: the ::::::: derived :::::: macros ::::::::::::::::: INT_LEASTMAX_MIN, ::::::::::::::::: INT_LEASTMAX_MAX :::: and ::::::::::::::::: UINT_LEASTMAX_MAX ::::: shall :::: not ::be :::: used ::: in :: an :::: #if :::::::::::: preprocessing ::::::::: directive, ::::: unless ::::: they ::: are :::::::: operand :: of ::: the :::::::: defined :::::::: operator.Question 7. Shall types [u]int_leastmax_t be added to the C standard as proposed in N2425? Question 8. If not, shall types with the indicated semantics of [u]int_leastmax_t as proposed in N2425 but with different names be added to the C standard?2.5. Chasing [u]intmax_t from standard interfacesTo avoid such situations where implementations get stuck because of early ABI choices, I think that it would be good to phase out all interfaces that use [u]intmax_t, and to replace them by type-generic macros, instead. These interfaces in the C standard are

-

  added a one-argument version of _ Static _ assert -harmonization with ISO/IEC 9945 (POSIX): • extended month name formats for strftime • integration of functions: memccpy, strdup, strndup -harmonization with floating point standard IEC 60559: • integration of binary floating-point technical specification TS 18661-1 • integration of decimal floating-point technical specification TS 18661-2 • integration of decimal floating-point technical specification TS 18661-4a -the macro DECIMAL _ DIG is declared obsolescent -added version test macros to certain library headers -added the attributes feature -added nodiscard, maybe _ unused and deprecated attributes A complete change history can be found in Annex M. Foreword xiii N2425 integers-new..exint-C2x working draft -September 13, 2019 ISO/IEC 9899:202x (E)

lllll

  PRIdN PRIdLEASTN PRIdFASTN PRIdMAX::::::::::::: PRIdLEASTMAX : PRIdPTR PRIiN PRIiLEASTN PRIiFASTN PRIiMAX ::::::::::::: PRIiLEASTMAX : PRIiPTR The fprintf macros for unsigned integers are: lllll PRIoN PRIoLEASTN PRIoFASTN PRIoMAX ::::::::::::: PRIoLEASTMAX : PRIoPTR PRIuN PRIuLEASTN PRIuFASTN PRIuMAX ::::::::::::: PRIuLEASTMAX : PRIuPTR PRIxN PRIxLEASTN PRIxFASTN PRIxMAX ::::::::::::: PRIxLEASTMAX : PRIxPTR PRIXN PRIXLEASTN PRIXFASTN PRIXMAX ::::::::::::: PRIXLEASTMAX : PRIXPTR The fscanf macros for signed integers are: lllll SCNdN SCNdLEASTN SCNdFASTN SCNdMAX ::::::::::::: SCNdLEASTMAX : SCNdPTR SCNiN SCNiLEASTN SCNiFASTN SCNiMAX ::::::::::::: SCNiLEASTMAX : SCNiPTR The fscanf macros for unsigned integers are: lllll SCNoN SCNoLEASTN SCNoFASTN SCNoMAX ::::::::::::: SCNoLEASTMAX : SCNoPTR SCNuN SCNuLEASTN SCNuFASTN SCNuMAX ::::::::::::: SCNuLEASTMAX : SCNuPTR SCNxN SCNxLEASTN SCNxFASTN SCNxMAX ::::::::::::: SCNxLEASTMAX : SCNxPTR

  ::::::: intmax _ t :::::::::: strtoimax : ( ::::: const ::::: char :: * :::::::: restrict ::::: nptr : , :: ::: :: ::: :::: char :: ** ::::::::: restrict ::::::: endptr : , :::: int ::::: base :) : ;:: [[ :::::::::: deprecated :: ]] ::::::::: uintmax _ t :::::::::: strtoumax : ( ::::: const ::::: char :: * :::::::: restrict ::::: nptr : , :: ::: :: ::: :::: char :: ** ::::::::: restrict ::::::: endptr : , :::: int ::::: base : ) : ;

  [[ :::::::::: deprecated :: ]] :::::::: intmax _ t :::::::::: wcstoimax : ( ::::: const :::::::: wchar _ t :: * ::::::: restrict ::::: nptr : , :: ::: :: ::: :::::: wchar _ t ::: ** :::::::: restrict ::::::: endptr : , :::: int ::::: base : ) : ; :: [[ :::::::::: deprecated :: ]] ::::::::: uintmax _ t :::::::::: wcstoumax : ( ::::: const :::::::: wchar _ t :: * ::::::: restrict ::::: nptr : , :: ::: :: ::: :::::: wchar _ t ::: ** :::::::: restrict ::::::: endptr : , :::: int ::::: base : ) : ;

:

  :::::::: promoted :::: type :: of :::: the :::::: second :::::::::: argument ::: for :: S. :::: The :::::: return :::: type :: R :: is ::::::::::: determined :: as ::::::::: indicated :: in ::::: each to ::::: these ::::::: macros ::::: shall :: be ::::::: integer ::::::::::: expressions. :7.8.3.1 The int _ abs type-generic macro Synopsis : # ::::::: include : <inttypes.h> : R :::::::: int _ abs : ( : T :: j : ) : ; ::::::::::: Description :::The : int _ abs type-generic macro ::::::::: computes ::: the :::::::: absolute :::::: value :: of ::: an ::::::: integer :: j. :: R :: is :::: the ::::::::: unsigned § 7.8.3.1 Library ISO/IEC 9899:202x (E) working draft -September 13, 2019 integers-new..exint-C2x N2425 ::::::: version :: of :: T. 234) ::::::: Returns :::The : int _ abs type-generic macro ::::::: returns ::: the :::::::: absolute :::::: value. :7.8.3.2 The int _ max type-generic macro Synopsis: # ::::::: include : <inttypes.h> : R :::::::: int _ max : ( : T :: j : , :: S : k : ) : ; ::::::::::: Description ::: The : int _ max type-generic macro :::::::: computes :::: the :::::::::: maximum :::::: value :: of ::::: two :::::::: integers :: j :::: and ::: k. ::: R :::: shall ::: be :::: the :::::::: common :::: real ::::: type ::: of ::::::: integer ::::: types :: T :::: and :: S ::: as ::::::::::: determined ::: by ::: the :::::: usual :::::::::: arithmetic ::::::::::: conversions. 235) ::::::: Returns ::: The : int _ max type-generic macro ::::::: returns ::: the :::::::::: maximum ::::: value :: of ::: its :::::::::: arguments. : 7.8.3.3 The int _ min type-generic macro Synopsis : # ::::::: include : <inttypes.h> : R :::::::: int _ min : ( : T :: j : , :: S : k : ) : ; ::::::::::: Constraints ::: The :::::: types : T :::: and :: S ::::: shall ::: be ::::::: integer ::::: types ::::: such :::: that ::::: there ::::: exists ::: an ::::::: integer ::::: type :::: that ::::::::: comprises :::: the ::::: value :::::: ranges ::: of ::::: both. 236) ::::::::::: Description ::: The : int _ min type-generic macro ::::::::: computes ::: the ::::::::: minimum :::::: value :: of :::: two :::::::: integers : j :::: and :: k. ::: If : T :::: and : : S :::: are ::::: either ::::: both ::::::: signed :: or ::::: both ::::::::: unsigned, :::: the :::::: return ::::: type :: R :::: shall ::: be ::::: their ::::::::: common :::: real :::: type ::: as :::::::::: determined ::: by ::: the :::::: usual :::::::::: arithmetic ::::::::::: conversions. ::::::::::: Otherwise, :: R :::: shall ::: be ::: the ::::::: signed ::::::: integer :::: type ::: of ::::::::: minimum :::: rank :::: that :::::::::: comprises ::: the ::::: value ::::::: ranges :: of ::::: both. : ::::::: Returns ::: The : int _ min type-generic macro ::::::: returns ::: the ::::::::: minimum :::::: value :: of ::: its :::::::::: arguments. : 7.8.3.4 The int _ div type-generic macro Synopsis : # ::::::: include : <inttypes.h> : R :::::::: int _ div : ( : T :::::: numer, :: S :::::: denom : ) : ; ::::::::::: Constraints : If :: T :: is ::: an ::::::::: unsigned :::: type :::: and :: S :: is : a ::::::: signed :::: type ::::: there ::::: shall ::: be : a ::::::: signed ::::::: integer :::: type :::: that :::::::::: comprises ::: the ::::: value :::::: range :: of :: T. 237) ::::::::::: Description ::: The : int _ div type-generic macro ::::::::: computes ::::::::::::::: numer / denom :::: and :::::::::::::::: numer % denom :: in :: a ::::::: single ::::::::: operation. ::: If :: T :: is ::: an ::::::::: unsigned ::::: type :::: and :: S :: is :: a ::::::: signed :::: type ::: let :: Q ::: be :::: the :::::: signed ::::::: integer ::::: type ::: of ::::::::: minimum ::::: rank :::: that :::::::::: comprises :::: the ::::: value :::::: range ::: of ::: T; ::::::::: otherwise ::: let :: Q ::: be ::: T. ::: If :: Q :: is :::: one ::: of :::: the ::::: types :::: int, :::::::::: long int :: or ::::::::::::::: long long int, :: R :: is ::::::: div _ t, ::::::: ldiv _ t ::: or :::::::: lldiv _ t, :::::::::::: respectively; :::::::::: otherwise 234) :

:FP

  237):If : T :: is :: the :::::: widest ::::::: unsigned ::::: integer ::: type :::: such : a :::: type :::: does :: not :::: exist. 180 Library § 7.8.3.4 N2425 integers-new..exint-C2x working draft -September 13, 2019 ISO/IEC 9899:202x (E) :R :: is :: a :::::::: structure ::::: type :::: that :::::::: contains ::: (in :::::: either :::::: order) ::: the ::::::::: members ::::: quot :::: (the ::::::::: quotient) :::: and :::: rem :::: (the :::::::::: remainder), ::::: each :: of :::::: which :::: has :::: type :: Q. :4If :: S :: is ::::::: signed :::: and ::::::::::::::::::::::::::::::::: int _ abs(numer)< int _ abs(denom) ::::::: holds, ::: the :::::: result :::: has : a ::::::::: quotient :: of :::::: value : 0 :::: and :: a :::::::::: remainder :: of :::::: value ::::::: numer. ::::::::::: Otherwise, :::::: numer :::: and :::::: denom :::: are :::::::::: converted :: to :: Q :::::: before :::: the :::::::::The : int _ div type-generic macro :::::: returns :: a :::::::: structure ::: of : a ::::: type : R ::::::::::: comprising :::: both :::: the :::::::: quotient :::: and ::: the :::::::::: remainder. :: If ::::: either ::::: part :: of ::: the :::::: result :::::: cannot ::: be ::::::::::: represented, ::: the ::::::::: behavior :: is ::::::::: undefined. § 7.8.3.4 Library ISO/IEC 9899:202x (E) working draft -September 13, 2019 integers-new..exint-C2x N2425 The math rounding direction macros represent the rounding directions of the functions ceil, floor, trunc, round, and roundeven, respectively, that convert to integral values in floating-point formats. They expand to integer constant expressions with distinct values suitable for use as the second argument to the fromfp, ufromfp, fromfpx, and ufromfpx functions :::::: toint, :::::::: touint, :::::::: tointx, :::: and ::::::::: touintx :::::::::::: type-generic ::::::: macros, ::: see :::: 7.25. The macro FP _ FAST _ FMA is optionally defined. If defined, it indicates that the fma function generally executes about as fast as, or faster than, a multiply and an add of double operands. 246) The macros FP _ FAST _ FMAF FP _ FAST _ FMAL are, respectively, float and long double analogs of FP _ FAST _ FMA. If defined, these macros expand to the integer constant 1. are, respectively, _ Decimal32, _ Decimal64, and _ Decimal128 analogs of FP _ FAST _ FMA.is optionally defined. If defined, it indicates that the corresponding function generally executes about as fast, or faster, than the corresponding operation or function of the argument type with result type the same as the argument type followed by conversion to the narrower type. For FP _ FAST _ FFMA, FP _ FAST _ FFMAL, and FP _ FAST _ DFMAL, the comparison is to a call to fma or fmal followed by a conversion, not to separate multiply, add, and conversion. If defined, these macros expand to the integer constant 1.

  pow functions Synopsis #include <math.h> double pow(double x, double y); float powf(float x, float y); long double powl(long double x, long double y); #ifdef __ STDC _ IEC _ 60559 _ DFP __ _ Decimal32 powd32( _ Decimal32 x, _ Decimal32 y); _ Decimal64 powd64( _ Decimal64 x, _ Decimal64 y); _ Decimal128 powd128( _ Decimal128 x, _ Decimal128 y); #endif

  y, double x); float powrf(float y, float x); long double powrl(long double y, long double x); #ifdef __ STDC _ IEC _ 60559 _ DFP __ _ Decimal32 powrd32( _ Decimal32 y, _ Decimal32 x); _ Decimal64 powrd64( _ Decimal64 y, _ Decimal64 x); _ Decimal128 powrd128( _ Decimal128 y, _ Decimal128 x);

  x, double y); float fmodf(float x, float y); long double fmodl(long double x, long double y); #ifdef __ STDC _ IEC _ 60559 _ DFP __ _ Decimal32 fmodd32( _ Decimal32 x, _ Decimal32 y); _ Decimal64 fmodd64( _ Decimal64 x, _ Decimal64 y); _ Decimal128 fmodd128( _ Decimal128 x, _ Decimal128 y); #endif

:

  If :::::: either :: of :::: the ::::: types ::::::::::: int _ least : N _ t :: or ::::::::::: uint _ least :: N _ t ::: are ::::::::: provided, ::: the :::::: other :: is ::::::::: provided, :::: too, :::and ::::: they ::: are ::: the ::::::::::::: corresponding ::::::: signed :: an ::::::::: unsigned ::::: types :: of ::::: each ::::: other. :: If :::: the ::::: types :::::::::: int _ least :: N _ t :::

:

  If :::::: either :: of ::: the :::::: types ::::::::: int _ fast :: N _ t :: or :::::::::: uint _ fast :: N _ t :: are ::::::::: provided, :::: the ::::: other :: is ::::::::: provided, :::: too, :::: and :::: they ::: are ::: the :::::::::::::: corresponding :::::: signed ::: an ::::::::: unsigned ::::: types :: of ::::: each ::::: other. :: If :::: the ::::: types ::::::::: int _ fast :: N _ t :::: and ::::::::: int _ fast ::

  an ::::::::: unsigned ::::::: integer ::::: type, ::::::::::: respectively, :::: that :::: are :: at ::::: least :: as ::::: wide ::: as ::: any ::::: basic ::::::: integer ::::: type, :::: the ::::::::::: int _ fast64 _ t ::::::::::::::: int _ least64 _ t :::::::::: ptrdiff _ t :::::::::::::: sig _ atomic _ t ::::::: size _ t ::::::::::::::: uint _ fast64 _ t :::::::::::::::: uint _ least64 _ t :::::::: wchar _ t :::::::

  8.1) :::::: without ::::::: breaking ::::: binary :::::::::: compatibility.:::::::: Application :::: code ::: can :::: then :::: query ::: the ::: type ::: and :::: print :: it :: by :::: using ::: the ::::::::: appropriate ::::: macros: : uintmax _ t :: ::: : # ::::::: include :: < ::::: stdint : . : h : > :: ::: : # ::::::: include :: < :::: stdio : . : h : > :: ::: : # ::::::: include :: < ::::::: inttypes : . : h : > :: ::: : # ::::: ifdef ::::::::::: UINT128 _ MAX :: ::: :::::::typedef ::::::::: uint128 _ t ::::::: bitset : ; :::::::::::: uint _ least64 _ t ::::::: bitset : ; :: all :: = :::: -1;:: ::: :: ::: :::::printf :: (" ::: the :::::::: largest :::: set ::: is :::: %#" :::::::::::: PRIXLEASTMAX ::: "\ : n :: ", :: ( ::::::::::::::: uint _ leastmax _ t : )Unless :::::: some :::::::: typedef ::: in :::: the :::::: library ::::::: clause :::::::: enforces :::::::::: otherwise, ::: it :: is :::::::::::::: recommended :: to :::::::: resolve ::::::::: intmax _ t :: to ::::::: signed :::::: long :::: int :: or ::::::: signed ::::: long :::::: long :::: int. ::: It :: is ::::::::::::: recommended ::::: that ::: the :::::: same ::: set ::

:#

  :::::: define ::::::::::: UINT128 _ MAX ::::: (~(( ::::::::: uint128 _ t : ) :: +0 : define :::::::::: INT128 _ MAX :::::: ((((( :::::::: int128 _ t : ) ::: +1) :::::: <<126) define :::::::::: INT128 _ MIN ::: (-:::::::::: INT128 _ MAX ::: -1) :::::::::: Nevertheless, : in ::: #if ::::::::: expressions :::: these ::::: macros :::::: expand :: to :::: valid ::::: integer ::::::::: expressions :: but :::: will ::: only :::::: evaluate :: to ::: the :::: same ::::: values : as :::::::::: UINT64 _ MAX, :::::::: INT64 _ MAX ::: and ::::::::: INT64 _ MIN, ::::::::: respectively. : N :: is ::::::: greater :::: than ::::::::::::::: UINTMAX _ WIDTH :::: and :::: the ::::::::::::: corresponding :::::::: macros INT : N _ C :: or : UINT : N _ C ::: are :::: not ::::::: defined, :::: the :::::::: derived ::::: _ MIN :::: and :::::: _ MAX ::::::: macros ::: for :::: the :::::::::::: exact-width, :::::::::::::::: minimum-width :::: and ::::::: fastest ::::::::::::::: minimum-width ::::: types ::: for ::: N :::: shall :::: not ::: be ::::: used :: in ::: an :::: #if ::::::::::::: preprocessing ::::::::: directive, :::::: unless :::: they :::: are ::::::: operand ::: of ::: the :::::::: defined :::::::: operator. : : If :::: the :::::::: macros : INT _ LEASTMAX _ C ::: and : UINT _ LEASTMAX _ C :: are :::: not :::::::: defined, :::: the :::::::: derived :::::::: macros : :::::::::::::::::: INT _ LEASTMAX _ MIN, :::::::::::::::::: INT _ LEASTMAX _ MAX :::: and :::::::::::::::::::: UINT _ LEASTMAX _ MAX ::::: shall :::: not ::: be ::::: used :: in :::: an :::: #if :::::::::::: preprocessing ::::::::: directive, :::::: unless ::::: they ::: are :::::::: operand :: of ::: the :::::::: defined ::::::::: operator. 288) ::::::::::::::::::::: Recommended practice ::::::: Because :: of :::: the :::::: above :::::::::: constraints, :::::::::::: applications ::::::: should ::::: prefer :::: the ::::::: _ WIDTH ::::::: macros :::: over :::: the ::::: _ MIN :: or : ::::_ MAX ::::::: macros ::: for ::::::: feature :::: tests ::: in ::: #if ::::::::::::: preprocessing :::::::::: directives.288):::

  if __ STDC _ WANT _ IEC _ 60559 _ BFP _ EXT __ is defined as a macro at the point in the source file where <float.h> is first included. If defined, CR _ DECIMAL _ DIG expands to an integral constant expression suitable for use in #if preprocessing directives whose value is a number such that conversions between all supported IEC 60559 binary formats and character sequences with at most CR _ DECIMAL _ DIG significant decimal digits are correctly rounded. The value of CR _ DECIMAL _ DIG shall be at least M + 3, where M is the maximum value of the T _ DECIMAL _ DIG macros for IEC 60559 binary formats. If the implementation correctly rounds for all numbers of significant decimal digits, then CR _ DECIMAL _ DIG shall have the value of the macro UINTMAX _ MAX.

:

  ::::: touintx , rint, lrint, llrint, and nearbyint in <tgmath.h> :::and <math.h> : , ::::::::: respectively. 390) The intermediate conversion is exact only if all input digits after the first CR _ DECIMAL _ DIG digits are 0.

strtoimax and strtoumax functions Synopsis

#include <inttypes.h> intmax _ t strtoimax(const char * restrict nptr, char ** restrict endptr, int base); uintmax _ t strtoumax(const char * restrict nptr, char ** restrict endptr, int base); ::

4 The wcstoimax and wcstoumax functions Synopsis #include <stddef

  strtoimax and strtoumax functions return the converted value, if any. If no conversion could be performed, zero is returned. If the correct value is outside the range of representable values, INTMAX _ MAX, INTMAX _ MIN, or UINTMAX _ MAX is returned (according to the return type and sign of the value, if any), and the value of the macro ERANGE is stored in errno. .h> // for wchar _ t #include <inttypes.h> intmax _ t wcstoimax(const wchar _ t * restrict nptr, wchar _ t ** restrict endptr, int base); uintmax _ t wcstoumax(const wchar _ t * restrict nptr, wchar _ t ** restrict endptr, int base);

Forward references: the strtol, strtoll, strtoul, and strtoull functions (7.22.1.7).

7.8.2.

::

8 The roundeven functions

	Synopsis
	#include <math.h>
	double roundeven(double x);
	float roundevenf(float x);
	long double roundevenl(long double x); #ifdef __ STDC _ IEC _ 60559 _ DFP __ _ Decimal32 roundevend32( _ Decimal32 x); _ Decimal64 roundevend64( _ Decimal64 x); _ Decimal128 roundevend128( _ Decimal128 x);
	#endif

7.12.10.2 The remainder functions Synopsis

#include <math.h> double remainder(double x, double y); float remainderf(float x, float y); long double remainderl(long double x, long double y); #ifdef __ STDC _ IEC _ 60559 _ DFP __ ISO/IEC 9899:202x (E) working draft -September 13, 2019 integers-new..exint-C2x N2425

  286) The exact-width and pointer-holding integer types are optional.

	N2425 integers-new..exint-C2x working draft -September 13, 2019	ISO/IEC 9899:202x (E)
	INTN _ WIDTH UINTN _ WIDTH	exactly N exactly N
	7.20.2.2 Width of minimum-width integer types
	INT _ LEASTN _ WIDTH UINT _ LEASTN _ WIDTH	exactly UINT _ LEASTN _ WIDTH N
	7.20.2.3 Width of fastest minimum-width integer types
	INT _ FASTN _ WIDTH UINT _ FASTN _ WIDTH	exactly UINT _ FASTN _ WIDTH N
	7.20.2.4 Width of integer types capable of holding object pointers
	INTPTR _ WIDTH UINTPTR _ WIDTH	exactly UINTPTR _ WIDTH 16
	7.20.2.5 Width of greatest-width integer types
	INTMAX _ WIDTH UINTMAX _ WIDTH INT _ LEASTMAX _ WIDTH UINT _ LEASTMAX _ WIDTH	exactly UINTMAX _ WIDTH 64 exactly UINT _ LEASTMAX _ WIDTH / * see above * /
	258	Library	§ 7.20.2.1

287) 7.20.3.1 Width of ptrdiff _ t PTRDIFF _ WIDTH 17

	7.20.3.2 Width of sig _ atomic _ t SIG _ ATOMIC _ WIDTH 7.20.3.3 Width of size _ t SIZE _ WIDTH 7.20.3.4 Width of wchar _ t WCHAR _ WIDTH 287) A freestanding implementation need not provide all of these types. 8 16 8 § 7.20.3.4 working draft -September 13, 2019 integers-new..exint-C2x N2425 7.20.3.5 Width of wint _ t Library ISO/IEC 9899:202x (E) WINT _ WIDTH 16

  The following 1190 :::: 1149 : identifiers or keywords are not covered by the above and have particular semantics provided by this document.

		uintmax _ t UINTMAX _ WIDTH UINTPTR _ MAX uintptr _ t UINTPTR _ WIDTH UINT _ WIDTH __ VA _ ARGS __
		wcscat wcscat _ s
		wcschr
		wcscmp
		wcscoll
		wcscpy wcscpy _ s
		wcscspn
		wcsftime
		wcslen
		wcsncat wcsncat _ s
		wcsncmp
		wcsncpy wcsncpy _ s wcsnlen _ s
		wcspbrk
		wcsrchr
		wcsrtombs wcsrtombs _ s
		wcsspn
		wcsstr
		wcsto
		wcstod
		wcstod128
		wcstod32
		wcstod64
		wcstof
		wcstoimax
		wcstok wcstok _ s
		wcstol
		wcstold
		wcstoll
	UINT _ LEASTMAX _ WIDTH UINT _ MAX UINTMAX _ C UINTMAX _ MAX	wcstombs wcstombs _ s wcstoul wcstoull wcstoumax wcsxfrm
	J.6.2 Particular identifiers or keywords
	1
	abort abort _ handler _ s	acos acosd128	acosd64 acosf
	abs	acosd32	acosh

231) See "future library directions" (7.31.6). 232) Separate macros are given for use with fprintf and fscanf functions because, in the general case, different format specifiers might be required for fprintf and fscanf, even when the type is the same.

233) The absolute value of the most negative number may not be representable.

246) Typically, the FP _ FAST _ FMA macro is defined if and only if the fma function is implemented directly with a hardware multiply-add instruction. Software implementations are expected to be substantially slower.

are required.

ISO/IEC 9899:202x (E)

working draft -September 13, 2019 integers-new..exint-C2x N2425 ::

of :::::::: complex ::::::: floating :::::: types. :::: IT ::::::::::: corresponds :: to :: a ::::::: signed :::::: integer ::::: type :::: that :::::::::: comprises ::: all :::::::::: admissible :::::: values ::: for ::: the ::::::::: operation ::: on :::: type ::: T. :: A :::::: macro ::: call ::::: with :::: first ::::::::: argument :: X :::: then :::: has ::: the ::::: same :::::: effects ::: as : if :: a :::::::: function :::: with :::: the ::::::::: indicated ::::::::: prototype ::: for ::: TX :::::: would ::: be :::::: called, :::::: where ::: TX :: is ::: the ::::: type :: of :: X :: if :::: that ::: has :: a ::::::: floating ::::: point ::::: type, :: or ::::::: double :::::::::: otherwise. : :::::::::::

Constraints

:::

The :::: first ::::::::: argument ::: to : a :::: call :: of ::::: these ::::::: macros :::: shall ::::::::::: correspond :: to ::: an :::::::::: expression :::: that ::: has :::::: either ::: one ::: of ::: the ::::::::: supported :::::: types :::::::: specified ::: for :: T :: or ::: has ::: an ::::::: integer ::::: type. :::: The :::::: second ::::::::: argument ::::: shall :: be ::: an ::::::: integer :::::::::: expression; :: if : it :::: has : a :::::: value :::: that :::::: cannot ::: be ::::::::: converted :: to :::: the :::: type ::: IT, :::: the :::::::: behavior :: is :::::::::: undefined. : error ::::: may ::::: occur :: if : x ::::::: equals : 0 :::: and :::::: n < 0.

:::::::

Returns

:::

The : pown type-generic macro ::::::: returns ::: x n .

The rootn type-generic macro Synopsis

#include <tgmath.h> T rootn(T x, IT n);

:::::::::::

Description

:::

The : rootn type-generic macro ::::::::: computes ::: the :::::::: principal : n :: The : rootn type-generic macro ::::::: returns ::: x 1 n ::::

with :::: the ::::: same :::: type ::: as :: x :: if :::: that :::: type :: is :: a ::::::: floating :::::: point ::::

type :: or ::::::: double :::::::::: otherwise. :

Nearest integer type-generic macros

::

In ::: the ::::::::: following ::::::::::::: specifications ::: the ::::: type :: T :: of ::: the ::::: first ::::::::: prototype :::::::::: parameter : x :::::::::::: corresponds :: to :: a :::: real :::::::

floating ::::: point :::: type :::: that :: is :::::::::: supported :: by ::: the ::::::::::::::: implementation. :::: The :::::: return ::::: types ::: ST :::: and :: UT ::::::::::: correspond ::

to :::::: signed :::: and ::::::::: unsigned ::::::: integer ::::: types, :::::::::::: respectively, :::: that ::: are :: at ::::: least :: as ::::: wide :: as ::::: long :::::: long. :: A :::::: macro TX :::::: would ::: be :::::: called, :::::: where ::: TX :: is ::: the :::: type ::: of : X :: if :::: that ::: has :: a ::::::: floating ::::: point ::::: type, :: or ::::::: double :::::::::: otherwise. :

:::::::::::

Constraints

:::

The :::: first :::::::::: argument :: to :: a ::: call ::: of ::::: these ::::::: macros ::::: shall :::::::::: correspond ::: to :: an :::::::::: expression ::::: that ::: has :::: one :: of :::: the :::::::::

supported ::::: types ::::::::: specified ::: for : T ::: or ::: has ::: an ::::::: integer ::::: type.

The toint and touint type-generic macros Synopsis

:: ::: :

# ::::::: include : <tgmath.h> :: ::: ::

ST :::::: toint : ( : T : x : , :::: int :::::: round : , ::::::::: unsigned :::: int :::::: width : ) : ;

:: ::: ::

UT ::::::: touint : ( : T : x : , :::: int :::::: round : , ::::::::: unsigned :::: int :::::: width : ) : ;

:::::::::::

Description

:::

The :::::: toint :::: and ::::::: touint :::::::::::: type-generic ::::::: macros :::::: round :: x, ::::: using :::: the ::::: math :::::::: rounding ::::::::: direction ::::::::: indicated ::

by ::::::: round, :: to :: a :::::: signed ::: or ::::::::: unsigned ::::::: integer, ::::::::::: respectively, ::: of :::::: width :::: bits, :::: and :::::: return :::: the ::::: result :::::: value ::

in ::: the ::::::: integer :::: type ::::::::::: designated :: by ::: ST ::: or ::: UT, ::::::::::: respectively. The ::::::: tointx :::: and :::::::: touintx :::::::::::: type-generic ::::::: macros :::::: return ::: the :::::::: rounded ::::::: integer :::::: value. NOTE ::::::::: Conversions :: to ::::: integer :::: types ::: that ::: are ::: not :::::: required :: to ::: raise ::: the ::::: inexact :::::::: exception ::: can :: be ::: done :::::: simply :: by ::::::: rounding :: to :::::

integral ::::: value :: in ::::: floating :::: type ::: and :::: then :::::::: converting : to ::: the :::: target :::::: integer :::: type. ::: For :::::: example, ::: the :::::::: conversion :: of :::: long ::::: double :: x : to :::::::: uint64 _ t, :::: using ::::::: upward ::::::: rounding, : is :::: done ::: by :: ::: : roundeven(±∞) returns ±∞.

The returned value is exact and is independent of the current rounding direction mode.

See the sample implementation for ceil in F.10.6.1.

F.10.6.9 The trunc functions

The trunc functions use IEC 60559 rounding toward zero (regardless of the current rounding direction).

trunc(±0) returns ±0.

trunc(±∞) returns ±∞.

The returned value is exact and is independent of the current rounding direction mode.

F.10.6.10 The toint and touint type-generic macros

The fromfp and ufromfp functions :::::: toint :::: and ::::::: touint :::::::::::: type-generic ::::::: macros : raise the "invalid" floating-point exception and return an unspecified value if the floating-point argument x is infinite or NaN or rounds to an integral value that is outside the range of any supported integer type of the specified width.

These functions ::::::::::: type-generic ::::::: macros : do not raise the "inexact" floating-point exception.

F.10.6.11 The tointx and touintx type-generic macros

The fromfpx and ufromfpx functions :::::: tointx :::: and :::::::: touintx :::::::::::: type-generic ::::::: macros raise the "invalid" floating-point exception and return an unspecified value if the floating-point argument x is infinite or NaN or rounds to an integral value that is outside the range of any supported integer type of the specified width.

These functions :::::::::::

type-generic ::::::: macros raise the "inexact" floating-point exception if a valid result differs in value from the floating-point argument x.

F.10.7 Remainder functions

F.10.7.1 The fmod functions fmod(±0, y) returns ±0 for y not zero.

fmod(x, y) returns a NaN and raises the "invalid" floating-point exception for x infinite or y zero (and neither is a NaN).

fmod(x, ±∞) returns x for x not infinite.

When subnormal results are supported, the returned value is exact and is independent of the current rounding direction mode.

The double version of fmod behaves as though implemented by

J.5.15 Additional stream types and file-opening modes

Additional mappings from files to streams are supported (7.21.2).

Additional file-opening modes may be specified by characters appended to the mode argument of the fopen function (7.21.5.3).

J.5.16 Defined file position indicator

The file position indicator is decremented by each successful call to the ungetc or ungetwc function for a text stream, except if its value was zero before a call (7.21.7.10, 7.29.3.10).

J.5.17 Math error reporting

Functions declared in <complex.h> and <math.h> raise SIGFPE to report errors instead of, or in addition to, setting errno or raising floating-point exceptions (7.3, 7.12).

J.6 Reserved identifiers and keywords

A lot of identifier preprocessing tokens are used for specific purposes in regular clauses or appendices from translation phase 3 onwards. Using any of these for a purpose different from their description in this document, even if the use is in a context where they are normatively permitted, may have an impact on the portability of code and should thus be avoided.

J.6.1 Rule based identifiers

The following 38 regular expressions characterize identifiers that are systematically reserved by some clause this document. The following 636 ::: 672 : identifiers or keywords match these patterns and have particular semantics provided by this document.

M.2 Fourth Edition

There were no major changes in the fourth edition ( __ STDC _ VERSION __ 201710L), only technical corrections and clarifications.

M.3 Third Edition

Major changes in the third edition ( __ STDC _ VERSION __ 201112L) included:

-conditional (optional) features (including some that were previously mandatory)