I have a variable and the type does not matter; the possible range will easily fit in any of the aforementioned types. For example a loop counter. Etc.
What are the pros and cons of using:
intunsigned intint_fastN_tuint_fastN_t
Note to any potential close-voters: I am not asking which ones to use, because that would be opinion-based, but I am asking, what factors should I consider when choosing one over the other?
Here are some factors to consider to make your choice:
If the bounds are integer literals, use the classic
rationale: the simpler the better.
if the bounds are variables, use the same type as that of the bound.
if the bounds may exceed the range of
int, use a larger type:longorint64_t... using theint_fastN_torint_leastN_tmakes the code harder to read and will not make a difference on most architectures.