Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

int32_t — an exactly 32-bit signed integer

int32_t from <stdint.h> names an exactly 32-bit signed integer type without padding bits. Its availability depends on the implementation.

Version: C23; repository compiler flag, production runtime not attested

Syntax

#include <stdint.h>
int32_t name = 0;

int32_t is a typedef name declared in <stdint.h>. It has exactly 32 bits, no padding bits, and a range from −2147483648 to 2147483647. It need not be an alias of int.

The type is optional; INT32_MAX can test its availability. When at least 32 bits suffice, the required type int_least32_t is an alternative. Signed arithmetic overflow has undefined behavior. For printing, use PRId32 from <inttypes.h> rather than assuming compatibility with %d.

Examples

#include <stdint.h>
#include <inttypes.h>
#include <stdio.h>

#ifndef INT32_MAX
#error "int32_t is required"
#else
int main(void)
{
    int32_t value = 123;
    printf("%" PRId32 "\n", value);
    return 0;
}
#endif

Result

123

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources