signed Signed integer specifier
signed Signed integer specifier
signed int equals int, but signed char differs from char. Query SCHAR_MIN and INT_MIN for limits; signed overflow is undefined, not wrapping.
| Category | Type specifiers |
|---|---|
| Kind | Keyword / Statement |
| C standard | C89 / C90 |
📝 Syntax
signed char sc = -128;
▶ Example
Edit the C code below and click Run; the server compiles and executes it:
Output:
SCHAR_MIN = -128
offset = -5
ℹ️ Info SCHAR_MIN = -128 reflects a common GCC 10.2 target with 8-bit bytes and two's-complement representation. The standard guarantees only that SCHAR_MIN is no greater than -127, so the example uses the macro rather than a hard-coded minimum.
🏷️ Related type specifiers
📚 Related Tutorials
❓ FAQ
QAre char and signed char the same type?
ANo. Even when an implementation gives plain char a signed representation, char and signed char remain distinct types. signed char unambiguously guarantees that negative values can be represented.
QShould code use signed int or int?
AThey are exactly equivalent, so the shorter int is customary. signed is more useful for signed char or when explicitly emphasizing signedness for teaching purposes.
QCan -128 always be used as the minimum signed char value?
ANo. The standard requires only that signed char's minimum be no greater than -127. Portable code should use SCHAR_MIN from limits.h and handle boundaries according to the target implementation.