Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

signed char — a one-byte signed integer type

`signed char` stores small signed integers. It is a distinct type from both plain `char` and `unsigned char`.

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

Syntax

signed char name = value;

signed char is a signed integer type. char, signed char, and unsigned char are three distinct types; plain char has implementation-defined signedness.

sizeof(signed char) is 1, but a byte contains CHAR_BIT bits, not necessarily 8. C23 requires two's complement representation with no padding bits. With 8 bits, the range is -128 through 127; SCHAR_MIN and SCHAR_MAX in <limits.h> provide the limits.

Integer promotions convert signed char to int. Thus, in the example, delta + 20 has type int, and %d prints the promoted value of delta.

Examples

#include <stdio.h>

int main(void)
{
    signed char delta = -12;
    int result = delta + 20;

    printf("delta=%d\n", delta);
    printf("result=%d\n", result);
    printf("size=%zu\n", sizeof delta);
    return 0;
}

Result

delta=-12
result=8
size=1

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