In ISO/IEC 9899:2018 (C18), it is stated under 7.20.1.3:
7.20.1.3 Fastest minimum-width integer types
1 Each of the following types designates an integer type that is usually fastest268) to operate with among all integer types that have at least the specified width.
2 The typedef name
int_fastN_t
designates the fastest signed integer type with a width of at least N. The typedef nameuint_fastN_t
designates the fastest unsigned integer type with a width of at least N.3 The following types are required:
int_fast8_t
,int_fast16_t
,int_fast32_t
,int_fast64_t
,uint_fast8_t
,uint_fast16_t
,uint_fast32_t
,uint_fast64_t
All other types of this form are optional.
268) 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.
But it is not stated why these "fast" integer types are faster.
- Why are these fast integer types faster than the other integer types?
I tagged the question with C++, because the fast integer types are also available in C++17 in the header file of cstdint
. Unfortunately, in ISO/IEC 14882:2017 (C++17) there is no such section about their explanation; I had implemented that section otherwise in the question´s body.
Information: In C, they are declared in the header file of stdint.h
.
typedef
statements. So typically, it is done at the standard library level. Of course, the C standard puts no real restriction on what theytypedef
to - so for example a typical implementation is to makeint_fast32_t
atypedef
ofint
on a 32-bit system, but a hypothetical compiler could for example implement a__int_fast
intrinsic type and promise to do some fancy optimizations to pick the fastest machine type on a case-by-case basis for variables of that type, and then the library could justtypedef
to that. – Paroxysm