Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

int8_t — exactly 8-bit signed integer type

int8_t from <stdint.h> stores integers from -128 to 127. It is an optional type with exactly 8 bits and no padding bits.

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

Syntax

#include <stdint.h>
int8_t name = value;

int8_t is a typedef name from <stdint.h>, not a keyword. It has exactly 8 bits without padding; C23 uses two’s complement representation.

The type is optional. Test availability with INT8_MAX; INT8_MIN and INT8_MAX specify -128 and 127. If at least 8 bits suffice, use the required int_least8_t.

The example casts to int for %d. Where the integer promotions apply, int8_t promotes to int if it names a non-bit-precise type. In C23, int8_t may instead name a bit-precise integer type; expressions of that type that do not designate bit-fields are exempt from the integer promotions.

Examples

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

#ifndef INT8_MAX
#error "int8_t is required"
#else
int main(void)
{
    int8_t value = -42;
    printf("%d\n", (int)value);
    return 0;
}
#endif

Result

-42

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