CKTIS / C
_BitInt — bit-precise integers
C23 introduces _BitInt(N): an integer type with a specified width, either signed or unsigned.
Version: C23; repository compiler flag, production runtime not attested
Syntax
[signed | unsigned] _BitInt(N)_BitInt(N) is signed by default; unsigned _BitInt(N) is unsigned. N must be an integer constant expression: at least 2 for signed, 1 for unsigned, and at most BITINT_MAXWIDTH from <limits.h>.
Width includes the sign bit: _BitInt(5) ranges from −16 to 15; unsigned _BitInt(5) from 0 to 31. This does not mean a five-bit storage size.
Unsigned arithmetic wraps modulo 2^N; signed arithmetic overflow is undefined. Before printf, the example casts values to types matching %d and %u.
Examples
#include <stdio.h>
int main(void)
{
_BitInt(5) temperature = -7;
unsigned _BitInt(5) counter = 31;
counter += 1;
printf("%d %u\n", (int)temperature, (unsigned int)counter);
return 0;
}
Result
-7 0
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.